org.apache.sling.models.annotations.Optional Java Examples

The following examples show how to use org.apache.sling.models.annotations.Optional. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OptionalPrimitivesModel.java    From sling-org-apache-sling-models-impl with Apache License 2.0 5 votes vote down vote up
@Inject
public OptionalPrimitivesModel(
        @Optional byte byteValue,
        @Optional short shortValue,
        @Optional int intValue,
        @Optional long longValue,
        @Optional float floatValue,
        @Optional double doubleValue,
        @Optional char charValue,
        @Optional boolean booleanValue,
        @Optional Byte byteObjectValue,
        @Optional Short shortObjectValue,
        @Optional Integer intObjectValue,
        @Optional Long longObjectValue,
        @Optional Float floatObjectValue,
        @Optional Double doubleObjectValue,
        @Optional Character charObjectValue,
        @Optional Boolean booleanObjectValue) {
    this.byteValue = byteValue;
    this.shortValue = shortValue;
    this.intValue = intValue;
    this.longValue = longValue;
    this.floatValue = floatValue;
    this.doubleValue = doubleValue;
    this.charValue = charValue;
    this.booleanValue = booleanValue;
    this.byteObjectValue = byteObjectValue;
    this.shortObjectValue = shortObjectValue;
    this.intObjectValue = intObjectValue;
    this.longObjectValue = longObjectValue;
    this.floatObjectValue = floatObjectValue;
    this.doubleObjectValue = doubleObjectValue;
    this.charObjectValue = charObjectValue;
    this.booleanObjectValue = booleanObjectValue;
}
 
Example #2
Source File: AbstractInjectableElement.java    From sling-org-apache-sling-models-impl with Apache License 2.0 5 votes vote down vote up
private static boolean getOptional(AnnotatedElement element, InjectAnnotationProcessor annotationProcessor) {
    if (element.isAnnotationPresent(Optional.class)) {
        return true;
    }
    if (annotationProcessor != null) {
        Boolean optional = annotationProcessor.isOptional();
        if (optional != null) {
            return optional.booleanValue();
        }
    }
    return false;
}
 
Example #3
Source File: OptionalPrimitivesModel.java    From sling-org-apache-sling-models-impl with Apache License 2.0 4 votes vote down vote up
@Inject @Optional
public boolean getBooleanValue();
 
Example #4
Source File: ScriptModel.java    From APM with Apache License 2.0 4 votes vote down vote up
public static boolean isScript(Resource resource) {
  return java.util.Optional.ofNullable(resource)
      .map(child -> getArrayProperty(child, JcrConstants.JCR_MIXINTYPES).contains(ScriptNode.APM_SCRIPT))
      .orElse(false);
}
 
Example #5
Source File: OptionalPrimitivesModel.java    From sling-org-apache-sling-models-impl with Apache License 2.0 4 votes vote down vote up
@Inject @Optional
public Boolean getBooleanObjectValue();
 
Example #6
Source File: OptionalPrimitivesModel.java    From sling-org-apache-sling-models-impl with Apache License 2.0 4 votes vote down vote up
@Inject @Optional
public Character getCharObjectValue();
 
Example #7
Source File: OptionalPrimitivesModel.java    From sling-org-apache-sling-models-impl with Apache License 2.0 4 votes vote down vote up
@Inject @Optional
public Double getDoubleObjectValue();
 
Example #8
Source File: OptionalPrimitivesModel.java    From sling-org-apache-sling-models-impl with Apache License 2.0 4 votes vote down vote up
@Inject @Optional
public Float getFloatObjectValue();
 
Example #9
Source File: OptionalPrimitivesModel.java    From sling-org-apache-sling-models-impl with Apache License 2.0 4 votes vote down vote up
@Inject @Optional
public Long getLongObjectValue();
 
Example #10
Source File: OptionalPrimitivesModel.java    From sling-org-apache-sling-models-impl with Apache License 2.0 4 votes vote down vote up
@Inject @Optional
public Integer getIntObjectValue();
 
Example #11
Source File: OptionalPrimitivesModel.java    From sling-org-apache-sling-models-impl with Apache License 2.0 4 votes vote down vote up
@Inject @Optional
public Short getShortObjectValue();
 
Example #12
Source File: OptionalPrimitivesModel.java    From sling-org-apache-sling-models-impl with Apache License 2.0 4 votes vote down vote up
@Inject @Optional
public Byte getByteObjectValue();
 
Example #13
Source File: OptionalPrimitivesModel.java    From sling-org-apache-sling-models-impl with Apache License 2.0 4 votes vote down vote up
@Inject @Optional
public char getCharValue();
 
Example #14
Source File: OptionalPrimitivesModel.java    From sling-org-apache-sling-models-impl with Apache License 2.0 4 votes vote down vote up
@Inject @Optional
public double getDoubleValue();
 
Example #15
Source File: OptionalPrimitivesModel.java    From sling-org-apache-sling-models-impl with Apache License 2.0 4 votes vote down vote up
@Inject @Optional
public float getFloatValue();
 
Example #16
Source File: OptionalPrimitivesModel.java    From sling-org-apache-sling-models-impl with Apache License 2.0 4 votes vote down vote up
@Inject @Optional
public long getLongValue();
 
Example #17
Source File: OptionalPrimitivesModel.java    From sling-org-apache-sling-models-impl with Apache License 2.0 4 votes vote down vote up
@Inject @Optional
public int getIntValue();
 
Example #18
Source File: OptionalPrimitivesModel.java    From sling-org-apache-sling-models-impl with Apache License 2.0 4 votes vote down vote up
@Inject @Optional
public short getShortValue();
 
Example #19
Source File: OptionalPrimitivesModel.java    From sling-org-apache-sling-models-impl with Apache License 2.0 4 votes vote down vote up
@Inject @Optional
public byte getByteValue();
 
Example #20
Source File: PropertyModelWithDefaults.java    From sling-org-apache-sling-models-impl with Apache License 2.0 4 votes vote down vote up
@Inject @Optional @Default(values = "second default")
public String getSecond();
 
Example #21
Source File: PropertyModelWithDefaults.java    From sling-org-apache-sling-models-impl with Apache License 2.0 4 votes vote down vote up
@Inject @Optional @Default(values = "first default")
public String getFirst();
 
Example #22
Source File: SimplePropertyModel.java    From sling-org-apache-sling-models-impl with Apache License 2.0 4 votes vote down vote up
@Inject
@Optional
public String getSecond();