/** * Sets options from the passed enum class. Enum class must be Java enumeration and implement {@link EnumClass}. * * @param optionsEnum enum class */ @SuppressWarnings("unchecked") default void setOptionsEnum(Class<I> optionsEnum) { checkNotNullArgument(optionsEnum); if (!optionsEnum.isEnum() || !EnumClass.class.isAssignableFrom(optionsEnum)) { throw new IllegalArgumentException("Options class must be enumeration and implement EnumClass " + optionsEnum); } setOptions(new EnumOptions(optionsEnum)); }
/** * @return enumclass * @deprecated Use {@link #getOptions()} instead. */ @SuppressWarnings("unchecked") @Deprecated default Class<? extends EnumClass> getOptionsEnum() { Options options = getOptions(); if (options instanceof EnumOptions) { return ((EnumOptions) options).getEnumClass(); } return null; } }
protected LookupField createComponentForEnum() { if (enumClass == null) { throw new IllegalStateException("EnumClass parameter is not defined"); } LookupField lookupField = createLookupField(); //noinspection unchecked lookupField.setOptions(new EnumOptions(enumClass)); return lookupField; }
@SuppressWarnings("unchecked") @Override protected void valueBindingConnected(ValueSource<V> valueSource) { super.valueBindingConnected(valueSource); if (valueSource instanceof EntityValueSource) { MetaPropertyPath propertyPath = ((EntityValueSource) valueSource).getMetaPropertyPath(); MetaProperty metaProperty = propertyPath.getMetaProperty(); if (metaProperty.getRange().isEnum()) { //noinspection unchecked setOptions(new EnumOptions(metaProperty.getJavaType())); } if (DynamicAttributesUtils.isDynamicAttribute(metaProperty)) { CategoryAttribute categoryAttribute = DynamicAttributesUtils.getCategoryAttribute(metaProperty); if (categoryAttribute != null && categoryAttribute.getDataType() == PropertyType.ENUMERATION) { setOptionsMap((Map<String, V>) categoryAttribute.getLocalizedEnumerationMap()); } } } }
@SuppressWarnings("unchecked") @Override protected void valueBindingConnected(ValueSource<V> valueSource) { super.valueBindingConnected(valueSource); if (valueSource instanceof EntityValueSource) { MetaPropertyPath propertyPath = ((EntityValueSource) valueSource).getMetaPropertyPath(); MetaProperty metaProperty = propertyPath.getMetaProperty(); if (metaProperty.getRange().isEnum()) { //noinspection unchecked setOptions(new EnumOptions(metaProperty.getRange().asEnumeration().getJavaClass())); } if (DynamicAttributesUtils.isDynamicAttribute(metaProperty)) { CategoryAttribute categoryAttribute = DynamicAttributesUtils.getCategoryAttribute(metaProperty); if (categoryAttribute != null && categoryAttribute.getDataType() == PropertyType.ENUMERATION) { setOptionsMap((Map<String, I>) categoryAttribute.getLocalizedEnumerationMap()); } } } }
@SuppressWarnings("unchecked") @Override protected void valueBindingConnected(ValueSource<V> valueSource) { super.valueBindingConnected(valueSource); if (valueSource instanceof EntityValueSource) { MetaPropertyPath propertyPath = ((EntityValueSource) valueSource).getMetaPropertyPath(); MetaProperty metaProperty = propertyPath.getMetaProperty(); if (metaProperty.getRange().isEnum()) { //noinspection unchecked setOptions(new EnumOptions(metaProperty.getRange().asEnumeration().getJavaClass())); } if (DynamicAttributesUtils.isDynamicAttribute(metaProperty)) { CategoryAttribute categoryAttribute = DynamicAttributesUtils.getCategoryAttribute(metaProperty); if (categoryAttribute != null && categoryAttribute.getDataType() == PropertyType.ENUMERATION) { setOptionsMap((Map<String, I>) categoryAttribute.getLocalizedEnumerationMap()); } } } }