@Retention(value=RUNTIME) @Target(value=CONSTRUCTOR) @Documented public @interface EntityCreator
@Table
public class MyEntity {
@PartitionKey
private Long sensorId;
@ClusteringColumn
private Date date;
@Column
private Double value;
//Correct custom constructor with matching field name and type
@EntityCreator
public MyEntity(Long sensorId, Date date, Double value) {
this.sensorId = sensorId;
this.date = date;
this.value = value;
}
//Correct custom constructor with matching field name and type even if fewer parameters than existing field name
@EntityCreator
public MyEntity(Long sensorId, Date date) {
this.sensorId = sensorId;
this.date = date;
}
//Correct custom constructor with matching field name and autoboxed type (long)
@EntityCreator
public MyEntity(long sensorId, Date date, Double value) {
this.sensorId = sensorId;
this.date = date;
this.value = value;
}
//Correct custom constructor with declared field name and type
@EntityCreator({"sensorId", "date", "value"})
public MyEntity(Long id, Date date, Double value) {
this.sensorId = id;
this.date = date;
this.value = value;
}
//Incorrect custom constructor because non matching field name (myId)
@EntityCreator
public MyEntity(Long myId, Date date, Double value) {
this.sensorId = myId;
this.date = date;
this.value = value;
}
//Incorrect custom constructor because field name not found (sensor_id)
@EntityCreator({"sensor_id", "date", "value"})
public MyEntity(Long sensor_id, Date date, Double value) {
this.sensorId = sensor_id;
this.date = date;
this.value = value;
}
//Incorrect custom constructor because all field names are not declared (missing declaration of "value" in annotation)
@EntityCreator({"sensorId", "date"})
public MyEntity(Long sensor_id, Date date, Double value) {
this.sensorId = sensor_id;
this.date = date;
this.value = value;
}
}
public abstract String[] value
Copyright © 2012-2021. All Rights Reserved.