public DefaultSchemaEqualsHandler(){ super( SchemaProperties.CREATED_AT.getLabel(), SchemaProperties.LAST_ALTERED_AT.getLabel() , SchemaProperties.STATISTICS.getLabel() , SchemaProperties.DISPLAY_NAME.getLabel() , SchemaProperties.DISPLAY_REMARKS.getLabel() , SchemaProperties.VIRTUAL.getLabel() , SchemaProperties.OCTET_LENGTH.getLabel() , SchemaObjectProperties.ROWS.getLabel()); }
protected Boolean toBoolean(Object value){ return converters.convertObject(value==null?getDefaultValue():value, Boolean.class); }
@Override public boolean isEnabled(Object obj){ ISchemaProperty dependent=getDependent(); if (dependent!=null){ return dependent.isEnabled(obj); } return false; }
@Override public boolean isSetterInstanceof(Object obj){ if (getSetterPropertyClass()!=null){ return getSetterPropertyClass().isInstance(obj); } return isInstanceof(obj); }
@Override public boolean isGetterInstanceof(Object obj){ if (getGetterPropertyClass()!=null){ return getGetterPropertyClass().isInstance(obj); } return isInstanceof(obj); }
@Override public boolean isEnabled(Object obj){ SchemaProperties dependent=getDependent(); if (dependent!=null&&dependent.isInstanceof(obj)){ DataType dataType=(DataType)dependent.getValue(obj); if (dataType==null||dataType.isFixedSize()){ return true; } return dependent.isEnabled(obj); } return false; } @Override
@Override public Object getCloneValue(Object obj){ Object value=getValue(obj); if (value==null){ return null; } if(Converters.getDefault().isConvertable(value.getClass())){ return Converters.getDefault().copy(value); } if (value instanceof Set){ return CommonUtils.cloneSet((Set<?>)value); } if (value instanceof List){ return CommonUtils.cloneList((List<?>)value); } if (value instanceof Cloneable){ Method method; try { method = value.getClass().getMethod("clone"); return method.invoke(value); } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { throw new RuntimeException(e); } } return value; }
@Override public boolean isInstanceof(Object obj){ if (getPropertyClass()!=null){ return getPropertyClass().isInstance(obj); } return false; }
@Override public boolean isEnabled(Object obj){ SchemaProperties dependent=getDependent(); if (dependent!=null&&dependent.isInstanceof(obj)){ Long maxLength=(Long)dependent.getValue(obj); if (!CommonUtils.eq(maxLength, this.getValue(obj))){ return true; } return dependent.isEnabled(obj); } return false; } @Override
private static <V extends AbstractSchemaObject<?>> V getSchemaObjectFromParentInternal(String schemaName,String name, DbCommonObject<?> dbObject, BiFunction<String, Schema, V> func) { if (name==null) { return null; } String objSchemaName=(String)SchemaProperties.SCHEMA_NAME.getValue(dbObject); Schema schema; if (CommonUtils.eq(schemaName, objSchemaName)||schemaName==null){ schema = dbObject.getAncestor(Schema.class); } else{ SchemaCollection schemas = dbObject.getAncestor(SchemaCollection.class); if (schemas==null){ return null; } schema = schemas.get(schemaName); } if (schema == null) { return null; } V getObject=func.apply(name, schema); if (getObject != null) { return getObject; } return null; }
protected void addAlterSchema(DbObjectDifference difference, Map<String, Difference<?>> allDiff, List<SqlOperation> sqlList) { DbObjectDifference characterSetDiff = (DbObjectDifference) allDiff .get(SchemaProperties.CHARACTER_SET.getLabel()); DbObjectDifference collationDiff = (DbObjectDifference) allDiff .get(SchemaProperties.COLLATION.getLabel()); DbObjectDifference characterSemanticsDiff = (DbObjectDifference) allDiff .get(SchemaProperties.CHARACTER_SEMANTICS.getLabel()); addAlterSchema(difference, allDiff, characterSetDiff, collationDiff, characterSemanticsDiff, sqlList); }
protected Integer toInteger(Object value){ return converters.convertObject(value==null?getDefaultValue():value, Integer.class); }
/** * コンテキストへテーブル名の設定を行います * @param context * @param tableName */ protected void setTableName(ParametersContext context, String tableName){ context.put(SchemaProperties.TABLE_NAME.getLabel(), tableName); }
protected int toInt(Object value){ return converters.convertObject(value==null?getDefaultValue():value, int.class); }
public static boolean setDataTypeNameInternal(String dataTypeName, DataTypeNameProperty<?> prop) { if (prop instanceof AbstractColumn) { ((AbstractColumn<?>)prop).dataTypeName=dataTypeName; return true; } boolean bool= SimpleBeanUtils.setField(prop, SchemaProperties.DATA_TYPE_NAME.getLabel(), dataTypeName); return bool; }
/** * カラム名の追加 * */ public ToStringBuilder addColumnNames(final Collection<Column> columns) { return addColumnNames(SchemaProperties.COLUMN_NAME.getLabel(), columns); }
@SuppressWarnings("unchecked") default T setIndex(Index value){ if (this instanceof DbObject){ value=SchemaUtils.getIndexFromParent(value, (DbCommonObject<?>)this); } SimpleBeanUtils.setField(this, SchemaProperties.INDEX_NAME.getLabel().replaceAll("Name", ""), value); return (T)this; }
@SuppressWarnings("unchecked") default T setIndexTableSpace(TableSpace value){ if (this instanceof DbCommonObject){ value=SchemaUtils.getTableSpaceFromParent(value, (DbCommonObject<?>)this); } SimpleBeanUtils.setField(this, SchemaProperties.INDEX_TABLE_SPACE_NAME.getLabel().replaceAll("Name", ""), value); return (T)this; }
@SuppressWarnings("unchecked") default T setImplementationType(Type value){ if (this instanceof DbCommonObject){ value=SchemaUtils.getTypeFromParent(value, (DbCommonObject<?>)this); } SimpleBeanUtils.setField(this, SchemaProperties.IMPLEMENTATION_TYPE_NAME.getLabel().replaceAll("Name", ""), value); return (T)this; }