/** * token + ":" + expires + ":" + md5Hex(token + ":" + expires + ":" + secret) */ protected String doEncodeToken(String token, String expires) { Args.assertFalse(token.contains(":"), "The token must not contains character ':'"); String encoded = token + ":" + expires + ":" + sign(token, expires) ; //removes all the '=' characters StringBuilder sb = new StringBuilder(Base64.encode(encoded)); while (sb.charAt(sb.length() - 1) == '=') { sb.deleteCharAt(sb.length() - 1); } return sb.toString(); }
public PropertyChange(T dbObject,String property, Object oldValue, Object newValue) { Args.notNull(dbObject,"dbObject"); Args.notEmpty(property,"property"); Args.assertFalse(Objects.equals(oldValue, newValue), "oldValue must not equals to newValue"); this.dbObject = dbObject; this.property = property; this.oldValue = oldValue; this.newValue = newValue; }
Args.assertFalse(newOptimisticLockFieldName.equalsIgnoreCase(getFieldName()), "newOptimisticLockFieldName must not equals the field name");
public TypeInfo(Class<?> type, Type genericType, MTypeKind kind,Class<?> elementType, TypeInfo elementTypeInfo) { Args.notNull(type,"type"); Args.notNull(kind,"kind"); if(null != elementType){ Args.assertTrue(kind == MTypeKind.COLLECTION, "The element type must not be null if the kind is 'COLLECTION'"); Args.assertTrue(elementTypeInfo != null,"The element type info must not be null if the element type is not null"); }else{ Args.assertFalse(kind == MTypeKind.COLLECTION, "The element type must be null if the kind is not 'COLLECTION'"); Args.assertTrue(elementTypeInfo == null, "The element type info must be null if the element type is null"); } this.type = type; this.genericType = genericType; this.typeKind = kind; this.elementType = elementType; this.elementTypeInfo = elementTypeInfo; }
@Override public EntityMappingBuilder createEntityMappingByClass(MetadataContext context, Class<?> cls, boolean allowEmptyFields) { Args.notNull(cls,"class"); Args.assertFalse(isExplicitNonEntity(context,cls), "The class '" + cls.getName() + "' was declared as not an entity type explicitly"); EntityMappingBuilder emb = new EntityMappingBuilder().setEntityClass(cls); preMappingEntity(context, emb); //mapping entity's properties BeanType beanType = BeanType.of(cls); log.debug("Creating entity mapping for type : " + cls.getName()); mappingBeanProperties(context,emb,beanType); postMappingEntity(context, emb); finalMappingEntity(context, emb); //fields must be defined if(!allowEmptyFields && emb.getFieldMappings().isEmpty()){ throw new MetadataException("Entity's fields must not be empty in the java type '" + cls.getName() + "'"); } //primary keys must be defined /* todo : review this strategy. if(emb.getIdFieldMappings().isEmpty()){ throw new MetadataException("Entity's primary key(s) must not be empty in the java type '" + cls.getName() + "'"); } */ return emb; }
public DbTable(String catalog, String schema, String name, String type, boolean quoted, String comment, String primaryKeyName, String[] primaryKeyColumnNames, DbColumn[] columns, DbForeignKey[] foreignKeys, DbIndex[] indexes) { super(catalog, schema, name, quoted); Args.notEmpty(type,"table type"); Args.notEmpty(columns,"columns' of table '" + name + ""); Args.assertFalse(!Arrays2.isEmpty(primaryKeyColumnNames) && Strings.isEmpty(primaryKeyName), "primaryKeyName must not be empty if primary key exists"); this.type = type; this.comment = comment; this.columns = columns; this.foreignKeys = null == foreignKeys ? new DbForeignKey[]{} : foreignKeys; this.indexes = null == indexes ? new DbIndex[]{} : indexes; this.primaryKey = Arrays2.isEmpty(primaryKeyColumnNames) ? null : new DbPrimaryKey(primaryKeyName, primaryKeyColumnNames); this.primaryKeyColumns = fromNames(primaryKeyColumnNames); }