@Test public void testIsValidCsn() { assertTrue( Csn.isValid( "20100111202217.914000Z#000000#000#000000" ) ); }
public static boolean isValid( String value ) { if ( Strings.isEmpty( value ) ) { return false; } char[] chars = value.toCharArray(); if ( chars.length != 40 ) { return false; } for ( int pos = 0; pos < 4; pos++ ) { if ( !Chars.isDigit( chars[pos] ) ) { return false; } } switch ( chars[4] ) { case '0' : if ( !Chars.isDigit( chars[5] ) ) { return false; } if ( chars[5] == '0' ) { return false; } break; case '1' : if ( ( chars[5] != '0' ) && ( chars[5] != '1' ) && ( chars[5] != '2' ) ) { return false; } break; default : return false; } switch ( chars[6] ) { case '0' : if ( !Chars.isDigit( chars[7] ) ) { return false; } if ( chars[7] == '0' ) { return false; } break; case '1' : case '2' : if ( !Chars.isDigit( chars[7] ) ) { return false; } break; case '3' : if ( ( chars[7] != '0' ) && ( chars[7] != '1' ) ) { return false; } break; default : return false; } switch ( chars[8] ) { case '0' : case '1' : if ( !Chars.isDigit( chars[9] ) ) { return false; } break; case '2' : if ( ( chars[9] != '0' ) && ( chars[9] != '1' ) && ( chars[9] != '2' ) && ( chars[9] != '3' ) ) { return false; } break; default : return false; } switch ( chars[10] ) { case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : break; default : return false; } if ( !Chars.isDigit( chars[11] ) ) { return false; } switch ( chars[12] ) { case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : break; default : return false; } if ( !Chars.isDigit( chars[13] ) ) { return false; } if ( chars[14] != '.' ) { return false; } for ( int i = 0; i < 6; i++ ) { if ( !Chars.isDigit( chars[15 + i] ) ) { return false; } } if ( chars[21] != 'Z' ) { return false; } if ( chars[22] != '#' ) { return false; } if ( !Chars.isHex( ( byte ) chars[23] ) || !Chars.isHex( ( byte ) chars[24] ) || !Chars.isHex( ( byte ) chars[25] ) || !Chars.isHex( ( byte ) chars[26] ) || !Chars.isHex( ( byte ) chars[27] ) || !Chars.isHex( ( byte ) chars[28] ) ) { return false; } if ( chars[29] != '#' ) { return false; } if ( !Chars.isHex( ( byte ) chars[30] ) || !Chars.isHex( ( byte ) chars[31] ) || !Chars.isHex( ( byte ) chars[32] ) ) { return false; } if ( chars[33] != '#' ) { return false; } if ( !Chars.isHex( ( byte ) chars[34] ) || !Chars.isHex( ( byte ) chars[35] ) || !Chars.isHex( ( byte ) chars[36] ) || !Chars.isHex( ( byte ) chars[37] ) || !Chars.isHex( ( byte ) chars[38] ) || !Chars.isHex( ( byte ) chars[39] ) ) { return false; } return true; }
Csn implements Comparable<Csn> { public static boolean isValid( String value ) { if ( Strings.isEmpty( value ) ) { return false; } char[] chars = value.toCharArray(); if ( chars.length != 40 ) { return false; } for ( int pos = 0; pos < 4; pos++ ) { if ( !Chars.isDigit( chars[pos] ) ) { return false; } } switch ( chars[4] ) { case '0' : if ( !Chars.isDigit( chars[5] ) ) { return false; } if ( chars[5] == '0' ) { return false; } break; case '1' : if ( ( chars[5] != '0' ) && ( chars[5] != '1' ) && ( chars[5] != '2' ) ) { return false; } break; default : return false; } switch ( chars[6] ) { case '0' : if ( !Chars.isDigit( chars[7] ) ) { return false; } if ( chars[7] == '0' ) { return false; } break; case '1' : case '2' : if ( !Chars.isDigit( chars[7] ) ) { return false; } break; case '3' : if ( ( chars[7] != '0' ) && ( chars[7] != '1' ) ) { return false; } break; default : return false; } switch ( chars[8] ) { case '0' : case '1' : if ( !Chars.isDigit( chars[9] ) ) { return false; } break; case '2' : if ( ( chars[9] != '0' ) && ( chars[9] != '1' ) && ( chars[9] != '2' ) && ( chars[9] != '3' ) ) { return false; } break; default : return false; } switch ( chars[10] ) { case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : break; default : return false; } if ( !Chars.isDigit( chars[11] ) ) { return false; } switch ( chars[12] ) { case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : break; default : return false; } if ( !Chars.isDigit( chars[13] ) ) { return false; } if ( chars[14] != '.' ) { return false; } for ( int i = 0; i < 6; i++ ) { if ( !Chars.isDigit( chars[15 + i] ) ) { return false; } } if ( chars[21] != 'Z' ) { return false; } if ( chars[22] != '#' ) { return false; } if ( !Chars.isHex( ( byte ) chars[23] ) || !Chars.isHex( ( byte ) chars[24] ) || !Chars.isHex( ( byte ) chars[25] ) || !Chars.isHex( ( byte ) chars[26] ) || !Chars.isHex( ( byte ) chars[27] ) || !Chars.isHex( ( byte ) chars[28] ) ) { return false; } if ( chars[29] != '#' ) { return false; } if ( !Chars.isHex( ( byte ) chars[30] ) || !Chars.isHex( ( byte ) chars[31] ) || !Chars.isHex( ( byte ) chars[32] ) ) { return false; } if ( chars[33] != '#' ) { return false; } if ( !Chars.isHex( ( byte ) chars[34] ) || !Chars.isHex( ( byte ) chars[35] ) || !Chars.isHex( ( byte ) chars[36] ) || !Chars.isHex( ( byte ) chars[37] ) || !Chars.isHex( ( byte ) chars[38] ) || !Chars.isHex( ( byte ) chars[39] ) ) { return false; } return true; } }
Csn implements Comparable<Csn> { public static boolean isValid( String value ) { if ( Strings.isEmpty( value ) ) { return false; } char[] chars = value.toCharArray(); if ( chars.length != 40 ) { return false; } for ( int pos = 0; pos < 4; pos++ ) { if ( !Chars.isDigit( chars[pos] ) ) { return false; } } switch ( chars[4] ) { case '0' : if ( !Chars.isDigit( chars[5] ) ) { return false; } if ( chars[5] == '0' ) { return false; } break; case '1' : if ( ( chars[5] != '0' ) && ( chars[5] != '1' ) && ( chars[5] != '2' ) ) { return false; } break; default : return false; } switch ( chars[6] ) { case '0' : if ( !Chars.isDigit( chars[7] ) ) { return false; } if ( chars[7] == '0' ) { return false; } break; case '1' : case '2' : if ( !Chars.isDigit( chars[7] ) ) { return false; } break; case '3' : if ( ( chars[7] != '0' ) && ( chars[7] != '1' ) ) { return false; } break; default : return false; } switch ( chars[8] ) { case '0' : case '1' : if ( !Chars.isDigit( chars[9] ) ) { return false; } break; case '2' : if ( ( chars[9] != '0' ) && ( chars[9] != '1' ) && ( chars[9] != '2' ) && ( chars[9] != '3' ) ) { return false; } break; default : return false; } switch ( chars[10] ) { case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : break; default : return false; } if ( !Chars.isDigit( chars[11] ) ) { return false; } switch ( chars[12] ) { case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : break; default : return false; } if ( !Chars.isDigit( chars[13] ) ) { return false; } if ( chars[14] != '.' ) { return false; } for ( int i = 0; i < 6; i++ ) { if ( !Chars.isDigit( chars[15 + i] ) ) { return false; } } if ( chars[21] != 'Z' ) { return false; } if ( chars[22] != '#' ) { return false; } if ( !Chars.isHex( ( byte ) chars[23] ) || !Chars.isHex( ( byte ) chars[24] ) || !Chars.isHex( ( byte ) chars[25] ) || !Chars.isHex( ( byte ) chars[26] ) || !Chars.isHex( ( byte ) chars[27] ) || !Chars.isHex( ( byte ) chars[28] ) ) { return false; } if ( chars[29] != '#' ) { return false; } if ( !Chars.isHex( ( byte ) chars[30] ) || !Chars.isHex( ( byte ) chars[31] ) || !Chars.isHex( ( byte ) chars[32] ) ) { return false; } if ( chars[33] != '#' ) { return false; } if ( !Chars.isHex( ( byte ) chars[34] ) || !Chars.isHex( ( byte ) chars[35] ) || !Chars.isHex( ( byte ) chars[36] ) || !Chars.isHex( ( byte ) chars[37] ) || !Chars.isHex( ( byte ) chars[38] ) || !Chars.isHex( ( byte ) chars[39] ) ) { return false; } return true; } Csn( long timestamp, int changeCount, int replicaId, int operationNumber );  Csn( String value );   Csn( byte[] value ); }
Csn implements Comparable<Csn> { public static boolean isValid( String value ) { if ( Strings.isEmpty( value ) ) { return false; } char[] chars = value.toCharArray(); if ( chars.length != 40 ) { return false; } for ( int pos = 0; pos < 4; pos++ ) { if ( !Chars.isDigit( chars[pos] ) ) { return false; } } switch ( chars[4] ) { case '0' : if ( !Chars.isDigit( chars[5] ) ) { return false; } if ( chars[5] == '0' ) { return false; } break; case '1' : if ( ( chars[5] != '0' ) && ( chars[5] != '1' ) && ( chars[5] != '2' ) ) { return false; } break; default : return false; } switch ( chars[6] ) { case '0' : if ( !Chars.isDigit( chars[7] ) ) { return false; } if ( chars[7] == '0' ) { return false; } break; case '1' : case '2' : if ( !Chars.isDigit( chars[7] ) ) { return false; } break; case '3' : if ( ( chars[7] != '0' ) && ( chars[7] != '1' ) ) { return false; } break; default : return false; } switch ( chars[8] ) { case '0' : case '1' : if ( !Chars.isDigit( chars[9] ) ) { return false; } break; case '2' : if ( ( chars[9] != '0' ) && ( chars[9] != '1' ) && ( chars[9] != '2' ) && ( chars[9] != '3' ) ) { return false; } break; default : return false; } switch ( chars[10] ) { case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : break; default : return false; } if ( !Chars.isDigit( chars[11] ) ) { return false; } switch ( chars[12] ) { case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : break; default : return false; } if ( !Chars.isDigit( chars[13] ) ) { return false; } if ( chars[14] != '.' ) { return false; } for ( int i = 0; i < 6; i++ ) { if ( !Chars.isDigit( chars[15 + i] ) ) { return false; } } if ( chars[21] != 'Z' ) { return false; } if ( chars[22] != '#' ) { return false; } if ( !Chars.isHex( ( byte ) chars[23] ) || !Chars.isHex( ( byte ) chars[24] ) || !Chars.isHex( ( byte ) chars[25] ) || !Chars.isHex( ( byte ) chars[26] ) || !Chars.isHex( ( byte ) chars[27] ) || !Chars.isHex( ( byte ) chars[28] ) ) { return false; } if ( chars[29] != '#' ) { return false; } if ( !Chars.isHex( ( byte ) chars[30] ) || !Chars.isHex( ( byte ) chars[31] ) || !Chars.isHex( ( byte ) chars[32] ) ) { return false; } if ( chars[33] != '#' ) { return false; } if ( !Chars.isHex( ( byte ) chars[34] ) || !Chars.isHex( ( byte ) chars[35] ) || !Chars.isHex( ( byte ) chars[36] ) || !Chars.isHex( ( byte ) chars[37] ) || !Chars.isHex( ( byte ) chars[38] ) || !Chars.isHex( ( byte ) chars[39] ) ) { return false; } return true; } Csn( long timestamp, int changeCount, int replicaId, int operationNumber );  Csn( String value );   Csn( byte[] value ); static boolean isValid( String value ); byte[] getBytes(); long getTimestamp(); int getChangeCount(); int getReplicaId(); int getOperationNumber(); @Override String toString(); @Override int hashCode(); @Override boolean equals( Object o ); @Override int compareTo( Csn csn ); }
Csn implements Comparable<Csn> { public static boolean isValid( String value ) { if ( Strings.isEmpty( value ) ) { return false; } char[] chars = value.toCharArray(); if ( chars.length != 40 ) { return false; } for ( int pos = 0; pos < 4; pos++ ) { if ( !Chars.isDigit( chars[pos] ) ) { return false; } } switch ( chars[4] ) { case '0' : if ( !Chars.isDigit( chars[5] ) ) { return false; } if ( chars[5] == '0' ) { return false; } break; case '1' : if ( ( chars[5] != '0' ) && ( chars[5] != '1' ) && ( chars[5] != '2' ) ) { return false; } break; default : return false; } switch ( chars[6] ) { case '0' : if ( !Chars.isDigit( chars[7] ) ) { return false; } if ( chars[7] == '0' ) { return false; } break; case '1' : case '2' : if ( !Chars.isDigit( chars[7] ) ) { return false; } break; case '3' : if ( ( chars[7] != '0' ) && ( chars[7] != '1' ) ) { return false; } break; default : return false; } switch ( chars[8] ) { case '0' : case '1' : if ( !Chars.isDigit( chars[9] ) ) { return false; } break; case '2' : if ( ( chars[9] != '0' ) && ( chars[9] != '1' ) && ( chars[9] != '2' ) && ( chars[9] != '3' ) ) { return false; } break; default : return false; } switch ( chars[10] ) { case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : break; default : return false; } if ( !Chars.isDigit( chars[11] ) ) { return false; } switch ( chars[12] ) { case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : break; default : return false; } if ( !Chars.isDigit( chars[13] ) ) { return false; } if ( chars[14] != '.' ) { return false; } for ( int i = 0; i < 6; i++ ) { if ( !Chars.isDigit( chars[15 + i] ) ) { return false; } } if ( chars[21] != 'Z' ) { return false; } if ( chars[22] != '#' ) { return false; } if ( !Chars.isHex( ( byte ) chars[23] ) || !Chars.isHex( ( byte ) chars[24] ) || !Chars.isHex( ( byte ) chars[25] ) || !Chars.isHex( ( byte ) chars[26] ) || !Chars.isHex( ( byte ) chars[27] ) || !Chars.isHex( ( byte ) chars[28] ) ) { return false; } if ( chars[29] != '#' ) { return false; } if ( !Chars.isHex( ( byte ) chars[30] ) || !Chars.isHex( ( byte ) chars[31] ) || !Chars.isHex( ( byte ) chars[32] ) ) { return false; } if ( chars[33] != '#' ) { return false; } if ( !Chars.isHex( ( byte ) chars[34] ) || !Chars.isHex( ( byte ) chars[35] ) || !Chars.isHex( ( byte ) chars[36] ) || !Chars.isHex( ( byte ) chars[37] ) || !Chars.isHex( ( byte ) chars[38] ) || !Chars.isHex( ( byte ) chars[39] ) ) { return false; } return true; } Csn( long timestamp, int changeCount, int replicaId, int operationNumber );  Csn( String value );   Csn( byte[] value ); static boolean isValid( String value ); byte[] getBytes(); long getTimestamp(); int getChangeCount(); int getReplicaId(); int getOperationNumber(); @Override String toString(); @Override int hashCode(); @Override boolean equals( Object o ); @Override int compareTo( Csn csn );  }