Package com.exedio.cope.pattern
Class ColorField
- java.lang.Object
-
- com.exedio.cope.Feature
-
- com.exedio.cope.Pattern
-
- com.exedio.cope.pattern.ColorField
-
- All Implemented Interfaces:
Copyable
,ColorFunction
,Settable<Color>
,Serializable
public final class ColorField extends Pattern implements Settable<Color>, Copyable, ColorFunction
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ColorField()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ColorField
allowAlpha()
ColorFunction
bind(Join join)
ColorField
copy(CopyMapper mapper)
ColorField
defaultTo(Color defaultConstant)
Condition
equal(Color value)
SetValue<?>[]
execute(Color value, Item exceptionItem)
static Color
fromRGB(int rgb)
Converts a value for fieldgetRGB()
into a color.Color
get(Item item)
Color
getDefaultConstant()
Set<Class<? extends Throwable>>
getInitialExceptions()
Returns the exceptions possibly thrown, when setting a value for this settable.Class<?>
getInitialType()
IntegerField
getRGB()
Returns the field containing almost the result ofColor.getRGB()
of the persisted color.boolean
isAlphaAllowed()
If this method returns false, this ColorField allows opaque colors only.boolean
isFinal()
Returns true, if a value for the settable can be specified on the creation of an item only, thus cannot be modified later.boolean
isInitial()
Returns true, if a value for the settable should be specified on the creation of an item.boolean
isMandatory()
IsNullCondition<?>
isNotNull()
Condition
isNotOpaque()
IsNullCondition<?>
isNull()
Condition
isOpaque()
Condition
notEqual(Color value)
NOT EQUAL Condition.ColorField
optional()
void
set(Item item, Color value)
ColorField
toFinal()
static int
toRGB(Color color)
Returns the value for fieldgetRGB()
representing the given color.-
Methods inherited from class com.exedio.cope.Pattern
addSource, addSource, addSource, addSource, addSourceFeature, addSourceFeature, addSourceFeature, annotationField, equals, getGeneratedTypes, getSourceFeatures, getSourceFeaturesGather, getSourceFields, getSources, getSourceTypes, getType, hashCode, initialize, newSourceType, newSourceType, newSourceType, newSourceType, newSourceType, newSourceType, newType, newType, onMount, registerSource
-
Methods inherited from class com.exedio.cope.Feature
afterModelCreated, getAbstractType, getAnnotation, getID, getLocalizationKeys, getName, getPattern, isAnnotationPresent, isSourceAlready, mount, readResolve, requireMounted, toString, toString, writeReplace
-
-
-
-
Method Detail
-
copy
public ColorField copy(CopyMapper mapper)
-
toFinal
public ColorField toFinal()
-
optional
public ColorField optional()
-
defaultTo
public ColorField defaultTo(Color defaultConstant)
-
allowAlpha
public ColorField allowAlpha()
- See Also:
isAlphaAllowed()
-
isInitial
public boolean isInitial()
Description copied from interface:Settable
Returns true, if a value for the settable should be specified on the creation of an item.
-
isFinal
public boolean isFinal()
Description copied from interface:Settable
Returns true, if a value for the settable can be specified on the creation of an item only, thus cannot be modified later.
-
isMandatory
public boolean isMandatory()
- Specified by:
isMandatory
in interfaceSettable<Color>
-
getInitialType
public Class<?> getInitialType()
- Specified by:
getInitialType
in interfaceSettable<Color>
-
isAlphaAllowed
public boolean isAlphaAllowed()
If this method returns false, this ColorField allows opaque colors only. This means, thealpha value
must be 255. If this method returns true, this ColorField allows any colors with anyalpha value
.
-
getDefaultConstant
public Color getDefaultConstant()
-
getRGB
public IntegerField getRGB()
Returns the field containing almost the result ofColor.getRGB()
of the persisted color. The difference is as follows:For
Color.getRGB()
analpha value
of 255 means that the color is completely opaque and analpha value
of 0 means that the color is completely transparent.Values of the IntegerField returned by this method do have the reverse meaning: An alpha value of 255 means that the color is completely transparent and an alpha value of 0 means that the color is completely opaque.
This transformation ensures, that the persistent value of any opaque
Color
does not depend on whether theColorField
allows alpha
or not.
-
getInitialExceptions
public Set<Class<? extends Throwable>> getInitialExceptions()
Description copied from interface:Settable
Returns the exceptions possibly thrown, when setting a value for this settable.- Specified by:
getInitialExceptions
in interfaceSettable<Color>
-
toRGB
public static int toRGB(Color color)
Returns the value for fieldgetRGB()
representing the given color.
-
bind
public ColorFunction bind(Join join)
-
isNull
public IsNullCondition<?> isNull()
- Specified by:
isNull
in interfaceColorFunction
-
isNotNull
public IsNullCondition<?> isNotNull()
- Specified by:
isNotNull
in interfaceColorFunction
-
equal
public Condition equal(Color value)
- Specified by:
equal
in interfaceColorFunction
-
notEqual
public Condition notEqual(Color value)
NOT EQUAL Condition. Note: according to SQL, a NULL value is evaluated to unknown, so a NOT EQUAL using a non null RHS is false for null values- Specified by:
notEqual
in interfaceColorFunction
-
isOpaque
public Condition isOpaque()
-
isNotOpaque
public Condition isNotOpaque()
-
-