本文整理匯總了Java中org.netbeans.bean.validation.constraints.Constraint類的典型用法代碼示例。如果您正苦於以下問題:Java Constraint類的具體用法?Java Constraint怎麽用?Java Constraint使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Constraint類屬於org.netbeans.bean.validation.constraints包,在下文中一共展示了Constraint類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getAttributeConstraintsMap
import org.netbeans.bean.validation.constraints.Constraint; //導入依賴的package包/類
public Map<String, Constraint> getAttributeConstraintsMap() {
if (attributeConstraintsMap == null || !Objects.equals(getDataTypeLabel(), attributeConstraintsDataTypeBinding)) {//Objects.equals used -> getDataTypeLabel() could be null incase of EmbeddedId
Map<String, Constraint> completeConstraintsMap = getAttributeConstraints()
.stream()
.collect(Collectors.toMap(c -> c.getClass().getSimpleName(), c -> c, (c1, c2) -> c1));
Set<Class<? extends Constraint>> allConstraintsClass = getAllConstraintsClass().keySet();
Set<Class<? extends Constraint>> allowedConstraintsClass = getAttributeConstraintsClass();
attributeConstraintsMap = allowedConstraintsClass
.stream()
.collect(Collectors.toMap(
c -> c.getSimpleName(),
c -> completeConstraintsMap.get(c.getSimpleName()),
(c1, c2) -> c1
));
attributeConstraintsDataTypeBinding = cleanUnusedConstraint(attributeConstraintsDataTypeBinding, allConstraintsClass, completeConstraintsMap);
}
return attributeConstraintsMap;
}
示例2: bootAllConstraints
import org.netbeans.bean.validation.constraints.Constraint; //導入依賴的package包/類
/**
* @return the complete list of Constraint (old datatype Constraint instance
* and new created Constraint instance)
*/
private Set<Constraint> bootAllConstraints(Set<Constraint> constraints) {
Set<Class<? extends Constraint>> existingConstraints = constraints.stream().map(c -> c.getClass()).collect(toSet());
for (Class<? extends Constraint> constraintClass : ALL_CONSTRAINTS.keySet()) {
if (!existingConstraints.contains(constraintClass)) {
try {
constraints.add(constraintClass.newInstance());
} catch (InstantiationException | IllegalAccessException ex) {
Exceptions.printStackTrace(ex);
}
}
}
Set<Constraint> constraintsWrapper = CONSTRAINTS_SUPPLIER.get();
constraintsWrapper.addAll(constraints);
return constraintsWrapper;
}
示例3: getBeanValidation
import org.netbeans.bean.validation.constraints.Constraint; //導入依賴的package包/類
public static Set<Constraint> getBeanValidation(Element element) {
Set<Constraint> constraints = org.netbeans.jpa.modeler.spec.extend.Attribute.CONSTRAINTS_SUPPLIER.get();
for (AnnotationMirror annotationMirror : element.getAnnotationMirrors()) {
String annotationQualifiedName = getAnnotationQualifiedName(annotationMirror);
Class<? extends Constraint> bvClass = SUPPORTED_BV_REVENG_CLASS_SET.get(annotationQualifiedName);
if (bvClass != null) {
Constraint constraint = null;
try {
constraint = bvClass.newInstance();
} catch (InstantiationException | IllegalAccessException ex) {
ex.printStackTrace();
// Ignore
}
if (constraint != null) {
constraint.load(annotationMirror);
constraints.add(constraint);
}
}
}
return constraints;
}
示例4: getKeyConstraintsMap
import org.netbeans.bean.validation.constraints.Constraint; //導入依賴的package包/類
public Map<String, Constraint> getKeyConstraintsMap() {
if (keyConstraintsMap == null || !Objects.equals(getDataTypeLabel(), keyConstraintsDataTypeBinding)) {//Objects.equals used -> getDataTypeLabel() could be null incase of EmbeddedId
Map<String, Constraint> completeConstraintsMap = getKeyConstraints()
.stream()
.collect(Collectors.toMap(c -> c.getClass().getSimpleName(), c -> c, (c1, c2) -> c1));
Set<Class<? extends Constraint>> allConstraintsClass = getAllConstraintsClass().keySet();
Set<Class<? extends Constraint>> allowedConstraintsClass = getKeyConstraintsClass();
keyConstraintsMap = allowedConstraintsClass
.stream()
.collect(Collectors.toMap(c -> c.getSimpleName(), c -> completeConstraintsMap.get(c.getSimpleName()), (c1, c2) -> c1));
keyConstraintsDataTypeBinding = cleanUnusedConstraint(keyConstraintsDataTypeBinding, allConstraintsClass, completeConstraintsMap);
}
return keyConstraintsMap;
}
示例5: getValueConstraintsMap
import org.netbeans.bean.validation.constraints.Constraint; //導入依賴的package包/類
public Map<String, Constraint> getValueConstraintsMap() {
if (valueConstraintsMap == null || !Objects.equals(getDataTypeLabel(), valueConstraintsDataTypeBinding)) {//Objects.equals used -> getDataTypeLabel() could be null incase of EmbeddedId
Map<String, Constraint> completeConstraintsMap = getValueConstraints()
.stream()
.collect(Collectors.toMap(c -> c.getClass().getSimpleName(), c -> c, (c1, c2) -> c1));
Set<Class<? extends Constraint>> allConstraintsClass = getAllConstraintsClass().keySet();
Set<Class<? extends Constraint>> allowedConstraintsClass = getValueConstraintsClass();
valueConstraintsMap = allowedConstraintsClass
.stream()
.collect(Collectors.toMap(c -> c.getSimpleName(), c -> completeConstraintsMap.get(c.getSimpleName()), (c1, c2) -> c1));
valueConstraintsDataTypeBinding = cleanUnusedConstraint(valueConstraintsDataTypeBinding, allConstraintsClass, completeConstraintsMap);
}
return valueConstraintsMap;
}
示例6: cleanUnusedConstraint
import org.netbeans.bean.validation.constraints.Constraint; //導入依賴的package包/類
private String cleanUnusedConstraint(String constraintsDataTypeBinding, Set<Class<? extends Constraint>> allConstraintsClass, Map<String, Constraint> completeConstraintsMap) {
//after datatype change , clearConstraint/disable the non-applicable constraints
if (constraintsDataTypeBinding != null) {
allConstraintsClass//todo only non-visible
.stream()
.map(c -> completeConstraintsMap.get(c.getSimpleName()))
.forEach(Constraint::clear);
}
constraintsDataTypeBinding = getDataTypeLabel();
return constraintsDataTypeBinding;
}
示例7: getAllConstraintsClass
import org.netbeans.bean.validation.constraints.Constraint; //導入依賴的package包/類
/**
* Complete list of constraint class based
*/
private static Map<Class<? extends Constraint>, Integer> getAllConstraintsClass() {
Map<Class<? extends Constraint>, Integer> classes = new HashMap<>();
classes.put(Null.class, 1);
classes.put(NotNull.class, 2);
classes.put(NotEmpty.class, 3);
classes.put(NotBlank.class, 4);
classes.put(AssertFalse.class, 5);
classes.put(AssertTrue.class, 6);
classes.put(Past.class, 7);
classes.put(PastOrPresent.class, 8);
classes.put(Future.class, 9);
classes.put(FutureOrPresent.class, 10);
classes.put(Size.class, 11);
classes.put(Pattern.class, 12);
classes.put(Email.class, 13);
classes.put(Min.class, 14);
classes.put(Max.class, 15);
classes.put(DecimalMin.class, 16);
classes.put(DecimalMax.class, 17);
classes.put(Digits.class, 18);
classes.put(Negative.class, 19);
classes.put(NegativeOrZero.class, 20);
classes.put(Positive.class, 21);
classes.put(PositiveOrZero.class, 22);
return classes;
}
示例8: getCollectionTypeConstraintsClass
import org.netbeans.bean.validation.constraints.Constraint; //導入依賴的package包/類
protected Set<Class<? extends Constraint>> getCollectionTypeConstraintsClass() {
Set<Class<? extends Constraint>> classes = new LinkedHashSet<>();
classes.add(NotNull.class);
classes.add(Null.class);
classes.add(Size.class);
return classes;
}
示例9: getAttributeConstraints
import org.netbeans.bean.validation.constraints.Constraint; //導入依賴的package包/類
/**
* @return the constraints
*/
public Set<Constraint> getAttributeConstraints() {
if (attributeConstraints == null) {
attributeConstraints = CONSTRAINTS_SUPPLIER.get();
}
if (ALL_CONSTRAINTS.size() != attributeConstraints.size()) {
attributeConstraints = bootAllConstraints(attributeConstraints);
}
return attributeConstraints;
}
示例10: getKeyConstraints
import org.netbeans.bean.validation.constraints.Constraint; //導入依賴的package包/類
/**
* @return the constraints
*/
public Set<Constraint> getKeyConstraints() {
if (keyConstraints == null) {
keyConstraints = CONSTRAINTS_SUPPLIER.get();
}
if (ALL_CONSTRAINTS.size() != keyConstraints.size()) {
keyConstraints = bootAllConstraints(keyConstraints);
}
return keyConstraints;
}
示例11: getValueConstraints
import org.netbeans.bean.validation.constraints.Constraint; //導入依賴的package包/類
/**
* @return the constraints
*/
public Set<Constraint> getValueConstraints() {
if (valueConstraints == null) {
valueConstraints = CONSTRAINTS_SUPPLIER.get();
}
if (ALL_CONSTRAINTS.size() != valueConstraints.size()) {
valueConstraints = bootAllConstraints(valueConstraints);
}
return valueConstraints;
}
示例12: getAttributeConstraintsClass
import org.netbeans.bean.validation.constraints.Constraint; //導入依賴的package包/類
@Override
public Set<Class<? extends Constraint>> getAttributeConstraintsClass() {
// if(isOptionalReturnType()){
// return Collections.EMPTY_SET;
// }
return getConstraintsClass(getAttributeType());
}
示例13: getValueConstraintsClass
import org.netbeans.bean.validation.constraints.Constraint; //導入依賴的package包/類
@Override
public Set<Class<? extends Constraint>> getValueConstraintsClass() {
if (isArray(getAttributeType())) {
return getConstraintsClass(getArrayType(getAttributeType()));
} else {
return Collections.EMPTY_SET;
}
}
示例14: getKeyConstraintsClass
import org.netbeans.bean.validation.constraints.Constraint; //導入依賴的package包/類
@Override
public Set<Class<? extends Constraint>> getKeyConstraintsClass() {
if(!isMap(getCollectionType())){
return Collections.EMPTY_SET;
}
return getConstraintsClass(getMapKeyDataTypeLabel());
}
示例15: getConstraintSnippet
import org.netbeans.bean.validation.constraints.Constraint; //導入依賴的package包/類
protected List<ConstraintSnippet> getConstraintSnippet(Set<Constraint> constraints) {
List<ConstraintSnippet> snippets = new ArrayList<>();
for (Constraint constraint : constraints) {
if (!constraint.getSelected() || constraint.isEmpty()) {
continue;
}
ConstraintSnippet snippet = ConstraintSnippetFactory.getInstance(constraint);
if (snippet != null) {
snippets.add(snippet);
}
}
return snippets;
}