A better name for enforced empty values: TextAttributes.setEnforceEmpty()

This commit is contained in:
Rustam Vishnyakov
2015-08-26 22:56:34 +03:00
parent 16afae73c3
commit b7ea6f6ba8
3 changed files with 16 additions and 10 deletions
@@ -33,8 +33,9 @@ public class TextAttributes implements Cloneable {
public static final TextAttributes ERASE_MARKER = new TextAttributes();
private boolean myEnforcedDefaults;
private boolean myEnforceEmpty;
@SuppressWarnings("NullableProblems")
@NotNull
private AttributesFlyweight myAttrs;
@@ -72,7 +73,7 @@ public class TextAttributes implements Cloneable {
private TextAttributes(@NotNull AttributesFlyweight attributesFlyweight, boolean enforced) {
myAttrs = attributesFlyweight;
myEnforcedDefaults = enforced;
myEnforceEmpty = enforced;
}
public TextAttributes(@NotNull Element element) {
@@ -97,11 +98,11 @@ public class TextAttributes implements Cloneable {
}
public boolean isFallbackEnabled() {
return isEmpty() && !myEnforcedDefaults;
return isEmpty() && !myEnforceEmpty;
}
public boolean containsValue() {
return !isEmpty() || myEnforcedDefaults;
return !isEmpty() || myEnforceEmpty;
}
public void reset() {
@@ -178,7 +179,7 @@ public class TextAttributes implements Cloneable {
@Override
public TextAttributes clone() {
return new TextAttributes(myAttrs, myEnforcedDefaults);
return new TextAttributes(myAttrs, myEnforceEmpty);
}
public boolean equals(Object obj) {
@@ -202,7 +203,7 @@ public class TextAttributes implements Cloneable {
}
if (isEmpty()) {
myEnforcedDefaults = true;
myEnforceEmpty = true;
}
}
@@ -216,7 +217,12 @@ public class TextAttributes implements Cloneable {
getEffectColor() + "," + getErrorStripeColor() + "]";
}
public void setEnforcedDefaults(boolean enforcedDefaults) {
myEnforcedDefaults = enforcedDefaults;
/**
* Enforces empty attributes instead of treating empty values as undefined.
*
* @param enforceEmpty True if empty values should be used as is (fallback is disabled).
*/
public void setEnforceEmpty(boolean enforceEmpty) {
myEnforceEmpty = enforceEmpty;
}
}
@@ -65,7 +65,7 @@ class TextAttributesReader extends ValueElementReader {
FontStyle.read(this, element));
// needed for compatibility with TextAttributes(Element)
if (attributes.isEmpty()) {
attributes.setEnforcedDefaults(true);
attributes.setEnforceEmpty(true);
}
}
//noinspection unchecked
@@ -108,6 +108,6 @@ public abstract class TextAttributesDescription extends ColorAndFontDescription
@Override
public void setInherited(boolean isInherited) {
super.setInherited(isInherited);
myAttributes.setEnforcedDefaults(!isInherited);
myAttributes.setEnforceEmpty(!isInherited);
}
}