-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Sean Sundberg <[email protected]>
- Loading branch information
Showing
3 changed files
with
94 additions
and
73 deletions.
There are no files selected for viewing
78 changes: 78 additions & 0 deletions
78
src/main/java/com/ibm/openpages/support/models/BaseField.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package com.ibm.openpages.support.models; | ||
|
||
import com.ibm.openpages.support.util.FieldType; | ||
|
||
public abstract class BaseField<T> implements FieldMetadata, ResultLabel { | ||
final protected String originalValue; | ||
final protected String value; | ||
final protected String label; | ||
final protected FieldType<?> fieldType; | ||
|
||
protected BaseField(FieldGroup fieldGroup, String value, FieldType<?> fieldType) { | ||
this(fieldGroup, value, value, fieldType); | ||
} | ||
|
||
protected BaseField(FieldGroup fieldGroup, String value, String label, FieldType<?> fieldType) { | ||
this.originalValue = value; | ||
this.value = fieldGroup != null ? fieldGroup.fieldName(value) : value; | ||
this.label = label; | ||
this.fieldType = fieldType; | ||
} | ||
|
||
@Override | ||
public boolean isEnumField() { | ||
return fieldType.isEnumField(); | ||
} | ||
|
||
@Override | ||
public boolean isStringField() { | ||
return fieldType.isStringField(); | ||
} | ||
|
||
@Override | ||
public boolean isIntegerField() { | ||
return fieldType.isIntegerField(); | ||
} | ||
|
||
@Override | ||
public boolean isDecimalField() { | ||
return fieldType.isDecimalField(); | ||
} | ||
|
||
@Override | ||
public boolean isDateField() { | ||
return fieldType.isDateField(); | ||
} | ||
|
||
@Override | ||
public boolean isUserField() { | ||
return fieldType.isUserField(); | ||
} | ||
|
||
@Override | ||
public boolean isBooleanField() { | ||
return fieldType.isBooleanField(); | ||
} | ||
|
||
@Override | ||
public boolean isCurrencyField() { | ||
return fieldType.isCurrencyField(); | ||
} | ||
|
||
@Override | ||
public FieldType<?> fieldType() { | ||
return fieldType; | ||
} | ||
|
||
@Override | ||
public String value() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public String label() { | ||
return label; | ||
} | ||
|
||
abstract protected T withFieldGroup(FieldGroup fieldGroup); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters