Skip to content

Commit

Permalink
#11652 removing field instanciation checks, moving data integrity to …
Browse files Browse the repository at this point in the history
…factory
  • Loading branch information
wezell committed May 20, 2017
1 parent be82b56 commit ae31844
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ public abstract static class Builder implements FieldBuilder {

@Value.Check
public void check() {
super.check();


Preconditions.checkArgument(new FieldUtil().validDate(defaultValue()), this.getClass().getSimpleName() + " invalid defualt Value:" + defaultValue());

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public abstract static class Builder implements FieldBuilder {}

@Value.Check
public void check() {
super.check();

Preconditions.checkArgument(new FieldUtil().validDateTime(defaultValue()), this.getClass().getSimpleName() + " invalid defualt Value:" + defaultValue());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@
@Value.Immutable
public abstract class HostFolderField extends Field implements OnePerContentType {

@Value.Check
public void check() {
super.check();
if(iDate().before(legacyFieldDate))return;
Preconditions.checkArgument(indexed(),"Host Folder Fields must be indexed");
}

@Value.Default
@Override
public boolean indexed() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public List<SelectableValue> selectableValues() {

@Value.Check
public void check() {
super.check();

if(iDate().before(legacyFieldDate))return;
if(values()!=null){
String[] tempVals = StringUtil.split(values().replaceAll("\r\n","|").trim(), "|");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,7 @@ public String typeName(){
return LegacyFieldTypes.getLegacyName(TagField.class);
}

@Value.Check
public void check() {
super.check();
if(iDate().after(legacyFieldDate)){
Preconditions.checkArgument(indexed(),"Tag Fields must be indexed");
}
}

@Value.Default
@Override
public boolean indexed() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public Class type() {
@Value.Derived
@Override
public List<DataTypes> acceptedDataTypes(){
return ImmutableList.of(DataTypes.LONG_TEXT,DataTypes.TEXT, DataTypes.FLOAT, DataTypes.INTEGER);
return ImmutableList.of(DataTypes.TEXT,DataTypes.LONG_TEXT, DataTypes.FLOAT, DataTypes.INTEGER);
}
@Value.Default
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import com.dotcms.contenttype.util.FieldUtil;
import com.dotcms.repackage.com.google.common.collect.ImmutableList;
import com.dotmarketing.util.UtilMethods;
import com.dotcms.repackage.com.google.common.base.Preconditions;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
Expand Down Expand Up @@ -40,9 +41,9 @@ public abstract static class Builder implements FieldBuilder {}

@Value.Check
public void check() {
super.check();

Preconditions.checkArgument(new FieldUtil().validTime(defaultValue()), this.getClass().getSimpleName() + " invalid defualt Value:" + defaultValue());

if(UtilMethods.isSet(defaultValue())){
Preconditions.checkArgument(new FieldUtil().validTime(defaultValue()), this.getClass().getSimpleName() + " invalid defualt Value:" + defaultValue());
}
}
}

0 comments on commit ae31844

Please sign in to comment.