Created
May 10, 2017 14:10
-
-
Save g4s8/05bc39281d979fe012c99e67712ded59 to your computer and use it in GitHub Desktop.
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
public final class PrintedSpec { | |
private final int mode; | |
private final int size; | |
public PrintedSpec(int spec) { | |
this(MeasureSpec.getMode(spec), MeasureSpec.getSize(spec)); | |
} | |
private PrintedSpec(final int mode, final int size) { | |
this.mode = mode; | |
this.size = size; | |
} | |
private String mode() { | |
switch (this.mode) { | |
case MeasureSpec.AT_MOST: | |
return "at-most"; | |
case MeasureSpec.EXACTLY: | |
return "exactly"; | |
case MeasureSpec.UNSPECIFIED: | |
return "unspecified"; | |
default: | |
return String.format(Locale.UK, "invalid-mode(%d)", mode); | |
} | |
} | |
private String size() { | |
switch (this.mode) { | |
case MeasureSpec.AT_MOST: | |
case MeasureSpec.EXACTLY: | |
return String.format(Locale.UK, "(%d)", this.size); | |
default: | |
return ""; | |
} | |
} | |
@Override | |
public String toString() { | |
return String.format(Locale.UK, "%s%s", mode(), size()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment