notnull相关知识
-
@NotBlank注解地正确使用@NotNull:不能为null,但可以为empty@NotEmpty:不能为null,而且长度必须大于0@NotBlank:只能作用在String上,不能为null,而且调用trim()后,长度必须大于0案例:1.String name = null;@NotNull: false@NotEmpty:false @NotBlank:false 2.String name = "";@NotNull:true@NotEmpty: false@NotBlank: false3.String name = " ";@NotNull: true@NotEmpty: true@NotBlank: false4.String name = "Great 
-
mysql把主键定义为自动增长标识符类型1、把主键定义为自动增长标识符类型在mysql中,如果把表的主键设为auto_increment类型,数据库就会自动为主键赋值。例如:?123create table customers(id int auto_increment primary key notnull, name varchar(15)); insert into customers(name) values("name1"),("name2");一旦把id设为auto_increment类型,mysql数据库会自动按递增的方式为主键赋值。在MS SQLServer中,如果把表的主键设为identity类型,数据库就会自动为主键赋值。例如:?12345create table customers(id int identity(1,1) primary key notnull, name varchar(15)); insert into customers(name) valu
-
Pandas对NaN的操作import numpy as np import pandas as pd from pandas import Series,DataFrame n = np.nan type(n) #结果: <class 'float'> m = 1 m + n #结果为:nan s1 = Series([1,2,np.nan,3,4],index = ['A','B','C','D','E']) s1 还有判断Series中元素是否为nan的函数 s1.isnull() s1.notnull() dframe = DataFrame([[1,2,3],[np.nan,5,6],[7,np.nan,9],[np.nan,np.nan,np.nan]]) dframe df1 = dframe.dropna(axis =0) :删除含NaN的行 df1 = dframe.drop
-
参数验证 @Validated 和 @Valid 的区别来源:blog.csdn.net/qq_27680317/article/details/79970590 整编:Java技术栈(公众号ID:javastack) Spring Validation验证框架对参数的验证机制提供了@Validated(Spring's JSR-303 规范,是标准 JSR-303 的一个变种),javax提供了@Valid(标准JSR-303规范),配合 BindingResult 可以直接提供参数验证结果。其中对于字段的特定验证注解比如 @NotNull 等网上到处都有,这里不详述 在检验 Controller 的入参是否符合规范时,使用 @Validated 或者 @Valid 在基本验证功能上
notnull相关课程
notnull相关教程
- 2.3 密封类的原理 密封类原理其实挺简单,实际上就是在一个私有的抽象类内部再声明多个 Java 中嵌套类也就是 static class . 可以把上述代码反编译成 Java 代码验证下:public abstract class Expression { private Expression() {//密封类构造器私有化,防止密封类被外部实例化 } // $FF: synthetic method public Expression(DefaultConstructorMarker $constructor_marker) { this(); } public static final class Num extends Expression {//声明成static class静态类,也就是Expression的嵌套类 private final int value; public final int getValue() { return this.value; } public Num(int value) { super((DefaultConstructorMarker)null); this.value = value; } } public static final class Sum extends Expression {//声明成static class静态类,也就是Expression的嵌套类 @NotNull private final Expression left; @NotNull private final Expression right; @NotNull public final Expression getLeft() { return this.left; } @NotNull public final Expression getRight() { return this.right; } public Sum(@NotNull Expression left, @NotNull Expression right) { Intrinsics.checkParameterIsNotNull(left, "left"); Intrinsics.checkParameterIsNotNull(right, "right"); super((DefaultConstructorMarker)null); this.left = left; this.right = right; } }}
- 6. 类的 setter,getter 访问器 与 Java 不同的是,需要手动创建 setter,getter 方法;即使现在很多 IDEA 插件工具可以自动生成,但是从语言层面来说还是比较啰嗦的。所以 Kotlin 直接在语言的层面省去了。先来对比一下:public class Bird { private String color; private int age; private String type; public Bird(String color, int age, String type) { this.color = color; this.age = age; this.type = type; } public String getColor() { return color; } public void setColor(String color) { this.color = color; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public String getType() { return type; } public void setType(String type) { this.type = type; }}而对于 Kotlin 只需要简单一行即可达到以上实现:class Bird(var color: String, var age: Int, var type: String)//var修饰则表示color属性会自动生成setter,getter方法,如果是val修饰表示只读,那么只会生成getter方法为了进一步验证,看看这一行简单声明是否反编译成 java 代码是怎么样的public final class Bird { @NotNull private String color; private int age; @NotNull private String type; @NotNull public final String getColor() { return this.color; } public final void setColor(@NotNull String var1) { Intrinsics.checkParameterIsNotNull(var1, "<set-?>"); this.color = var1; } public final int getAge() { return this.age; } public final void setAge(int var1) { this.age = var1; } @NotNull public final String getType() { return this.type; } public final void setType(@NotNull String var1) { Intrinsics.checkParameterIsNotNull(var1, "<set-?>"); this.type = var1; } public Bird(@NotNull String color, int age, @NotNull String type) { Intrinsics.checkParameterIsNotNull(color, "color"); Intrinsics.checkParameterIsNotNull(type, "type"); super(); this.color = color; this.age = age; this.type = type; }}
- 3.3 数据类的原理 我们通过对比发现 Kotlin 中仅需要一行代码就能实现 Java 中 86 行代码功能,数据类到底有什么奥秘能做到这一点,其实这些都是编译器帮我们自动生成好的,我们可以通过反编译数据类 Kotlin 代码看下:public final class Student { @NotNull private String name; private int age; private double weight; @NotNull private String nickName; @NotNull private String address; //为属性生成了setter和getter方法 @NotNull public final String getName() { return this.name; } public final void setName(@NotNull String var1) { Intrinsics.checkParameterIsNotNull(var1, "<set-?>"); this.name = var1; } public final int getAge() { return this.age; } public final void setAge(int var1) { this.age = var1; } public final double getWeight() { return this.weight; } public final void setWeight(double var1) { this.weight = var1; } @NotNull public final String getNickName() { return this.nickName; } public final void setNickName(@NotNull String var1) { Intrinsics.checkParameterIsNotNull(var1, "<set-?>"); this.nickName = var1; } @NotNull public final String getAddress() { return this.address; } public final void setAddress(@NotNull String var1) { Intrinsics.checkParameterIsNotNull(var1, "<set-?>"); this.address = var1; } //生成了构造器方法 public Student(@NotNull String name, int age, double weight, @NotNull String nickName, @NotNull String address) { Intrinsics.checkParameterIsNotNull(name, "name"); Intrinsics.checkParameterIsNotNull(nickName, "nickName"); Intrinsics.checkParameterIsNotNull(address, "address"); super(); this.name = name; this.age = age; this.weight = weight; this.nickName = nickName; this.address = address; } //生成了component 1...N的解构函数,这个下面会详细说明 @NotNull public final String component1() { return this.name; } public final int component2() { return this.age; } public final double component3() { return this.weight; } @NotNull public final String component4() { return this.nickName; } @NotNull public final String component5() { return this.address; } //生成了copy函数,这个下面会详细说明 @NotNull public final Student copy(@NotNull String name, int age, double weight, @NotNull String nickName, @NotNull String address) { Intrinsics.checkParameterIsNotNull(name, "name"); Intrinsics.checkParameterIsNotNull(nickName, "nickName"); Intrinsics.checkParameterIsNotNull(address, "address"); return new Student(name, age, weight, nickName, address); } // $FF: synthetic method public static Student copy$default(Student var0, String var1, int var2, double var3, String var5, String var6, int var7, Object var8) { if ((var7 & 1) != 0) { var1 = var0.name; } if ((var7 & 2) != 0) { var2 = var0.age; } if ((var7 & 4) != 0) { var3 = var0.weight; } if ((var7 & 8) != 0) { var5 = var0.nickName; } if ((var7 & 16) != 0) { var6 = var0.address; } return var0.copy(var1, var2, var3, var5, var6); } //自动生成了toString @NotNull public String toString() { return "Student(name=" + this.name + ", age=" + this.age + ", weight=" + this.weight + ", nickName=" + this.nickName + ", address=" + this.address + ")"; } //自动生成了hashCode方法 public int hashCode() { String var10000 = this.name; int var1 = ((var10000 != null ? var10000.hashCode() : 0) * 31 + this.age) * 31; long var10001 = Double.doubleToLongBits(this.weight); var1 = (var1 + (int)(var10001 ^ var10001 >>> 32)) * 31; String var2 = this.nickName; var1 = (var1 + (var2 != null ? var2.hashCode() : 0)) * 31; var2 = this.address; return var1 + (var2 != null ? var2.hashCode() : 0); } //自动生成了equals方法 public boolean equals(@Nullable Object var1) { if (this != var1) { if (var1 instanceof Student) { Student var2 = (Student)var1; if (Intrinsics.areEqual(this.name, var2.name) && this.age == var2.age && Double.compare(this.weight, var2.weight) == 0 && Intrinsics.areEqual(this.nickName, var2.nickName) && Intrinsics.areEqual(this.address, var2.address)) { return true; } } return false; } else { return true; } }}
- 3.4 copy 方法 我们现在重点来分析下 copy 方法 @NotNull public final Student copy(@NotNull String name, int age, double weight, @NotNull String nickName, @NotNull String address) { Intrinsics.checkParameterIsNotNull(name, "name"); Intrinsics.checkParameterIsNotNull(nickName, "nickName"); Intrinsics.checkParameterIsNotNull(address, "address"); return new Student(name, age, weight, nickName, address); } // $FF: synthetic method public static Student copy$default(Student var0, String var1, int var2, double var3, String var5, String var6, int var7, Object var8) {//var0表示被copy的对象 if ((var7 & 1) != 0) { var1 = var0.name;//copy时如果未指定具体属性的值,则会使用被copy对象的属性值 } if ((var7 & 2) != 0) { var2 = var0.age; } if ((var7 & 4) != 0) { var3 = var0.weight; } if ((var7 & 8) != 0) { var5 = var0.nickName; } if ((var7 & 16) != 0) { var6 = var0.address; } return var0.copy(var1, var2, var3, var5, var6); }需要注意的是 copy 方法主要是帮助我们从已有的数据类对象中拷贝一个新的数据类对象。当然也可以传入不同参数来生成不同的对象,但是从代码中可以看出,如果一个属性并没有指定具体属性值,那么新生成的对象的值将使用被 copy 对象的属性值,也就是我们俗称的浅拷贝。
- 3.2 关系类图 Delegates : 是一个代理单例对象,里面有 notNull、observable、vetoable 静态方法,每个方法返回不同的类型代理对象;NotNullVar : notNull 方法返回代理对象的类;ObserableProperty : observable、vetoable方法返回代理对象的类;ReadOnlyProperty : 只读属性代理对象的通用接口;ReadWriteProperty : 读写属性代理对象的通用接口。
- 7. @JvmStatic @JvmStatic 的作用能被用在对象声明或者 Companion object 伴生对象的方法上,把它们暴露成一个 Java 的静态方法源码定义//作用于函数、属性、属性的setter和getter@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER)@MustBeDocumented@OptionalExpectationpublic expect annotation class JvmStatic()注解使用@JvmStatic 这个注解一般经常用于伴生对象的方法上,供给 Java 代码调用:class Data { companion object { fun getDefaultDataName(): String { return "default" } }}//在java中调用,只能是Data.Companion.getDefaultDataName()调用public class Test { public static void main(String[] args) { System.out.println(Data.Companion.getDefaultDataName()); }}反编译后 Java 代码:public final class Data { public static final Data.Companion Companion = new Data.Companion((DefaultConstructorMarker)null); public static final class Companion { @NotNull public final String getDefaultDataName() { return "default"; } private Companion() { } // $FF: synthetic method public Companion(DefaultConstructorMarker $constructor_marker) { this(); } }}使用 @JvmStatic 注解后:class Data { companion object { @JvmStatic fun getDefaultDataName(): String { return "default" } }}//在java中调用,可以直接这样Data.getDefaultDataName()调用public class Test { public static void main(String[] args) { System.out.println(Data.getDefaultDataName()); }}反编译后的 Java 代码public final class Data { public static final Data.Companion Companion = new Data.Companion((DefaultConstructorMarker)null); @JvmStatic @NotNull //注意它会在Data类内部自动生成一个getDefaultDataName,然后内部还是通过Companion.getDefaultDataName()去调用。 public static final String getDefaultDataName() { return Companion.getDefaultDataName(); } public static final class Companion { @JvmStatic @NotNull public final String getDefaultDataName() { return "default"; } private Companion() { } // $FF: synthetic method public Companion(DefaultConstructorMarker $constructor_marker) { this(); } }}
notnull相关搜索
-
net core
net mvc
net教程
net开发
name
navigate
navigationbar
navigator
navigator appname
navigator useragent
nba比赛结果
negatives
neicun
neon
net link
net mvc
netcore
netscape
netstat
netstat命令