litesoft
@ 917
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
// This Source Code is in the Public Domain per: http://litesoft.org/License.txt package org.litesoft.bo.attributes; import org.litesoft.core.typeutils.Objects; import java.util.*; public class Options implements PropertyOfAMD { public static Options of( String... pOptions ) { return Objects.isNotNullOrEmpty( pOptions ) ? new Options( pOptions ) : null; } public static String[] get( AttributeMetaData pAMD ) { PropertyOfAMD zProperty = pAMD.getProperties().get( MAP_KEY ); if ( zProperty != null ) { return ((Options) zProperty).mValue; } return null; } public static Integer getLength( AttributeMetaData pAMD ) { PropertyOfAMD zProperty = pAMD.getProperties().get( MAP_KEY ); if ( zProperty != null ) { return ((Options) zProperty).getLength(); } return null; } private static final String MAP_KEY = "Options"; private Integer mLength; private Integer getLength() { if ( mLength == null ) { int zMax = 2; for ( String zEntry : mValue ) { if ( zEntry != null ) { zMax = Math.max( zMax, zEntry.length() ); } } mLength = zMax; } return mLength; } private Options( String[] pValue ) { mValue = pValue; } private String[] mValue; @Override public String toString() { StringBuilder sb = new StringBuilder().append( MAP_KEY ).append( ".of( \"" ).append( mValue[0] ).append( '\"' ); for ( int i = 1; i < mValue.length; i++ ) { sb.append( ", \"" ).append( mValue[i] ).append( '\"' ); } return sb.append( " )" ).toString(); } public String getMapKey() { return MAP_KEY; } @Override public boolean equals( Object them ) { return (this == them) || ((them != null) && (this.getClass() == them.getClass()) && Arrays.equals( this.mValue, ((Options) them).mValue )); } @Override public int hashCode() { return mValue.length; } } |
Commits for litesoft/trunk/Java/core/Anywhere/src/org/litesoft/bo/attributes/Options.java
Revision | Author | Commited | Message |
---|---|---|---|
917 Diff | GeorgeS | Sun 08 Dec, 2013 20:49:56 +0000 | 1.7 prep & VersionedStaticContentFilter upgrade to new “/ver” model! |
809 Diff | GeorgeS | Thu 16 Aug, 2012 04:10:46 +0000 | |
151 Diff | GeorgeS | Thu 17 Mar, 2011 04:16:22 +0000 | |
49 Diff | GeorgeS | Mon 12 Apr, 2010 02:59:10 +0000 | License Text |
2 | GeorgeS | Sun 07 Feb, 2010 12:50:58 +0000 |