mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-30 18:15:39 +00:00
Instead of the Differences being passed around on their own, the DiffContext is able to provide more information -- at present just the Dialect. The dialect can be used to change the way database objects are validated or differenced. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@31466 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
117 lines
3.1 KiB
Java
117 lines
3.1 KiB
Java
/*
|
|
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
|
*
|
|
* This file is part of Alfresco
|
|
*
|
|
* Alfresco is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* Alfresco is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
package org.alfresco.util.schemacomp.model;
|
|
|
|
import org.alfresco.util.schemacomp.DiffContext;
|
|
import org.alfresco.util.schemacomp.Differences;
|
|
import org.alfresco.util.schemacomp.Result.Strength;
|
|
|
|
/**
|
|
* Represents a column in a database table.
|
|
*
|
|
* @author Matt Ward
|
|
*/
|
|
public class Column extends AbstractDbObject
|
|
{
|
|
private String type;
|
|
private boolean nullable;
|
|
|
|
|
|
/**
|
|
* Construct a Column.
|
|
*
|
|
* @param name
|
|
* @param type
|
|
* @param nullable
|
|
*/
|
|
public Column(String name, String type, boolean nullable)
|
|
{
|
|
super(name);
|
|
this.type = type;
|
|
this.nullable = nullable;
|
|
}
|
|
|
|
/**
|
|
* @return the type
|
|
*/
|
|
public String getType()
|
|
{
|
|
return this.type;
|
|
}
|
|
|
|
/**
|
|
* @param type the type to set
|
|
*/
|
|
public void setType(String type)
|
|
{
|
|
this.type = type;
|
|
}
|
|
|
|
/**
|
|
* @return the nullable
|
|
*/
|
|
public boolean isNullable()
|
|
{
|
|
return this.nullable;
|
|
}
|
|
|
|
/**
|
|
* @param nullable the nullable to set
|
|
*/
|
|
public void setNullable(boolean nullable)
|
|
{
|
|
this.nullable = nullable;
|
|
}
|
|
|
|
@Override
|
|
public int hashCode()
|
|
{
|
|
final int prime = 31;
|
|
int result = super.hashCode();
|
|
result = prime * result + (this.nullable ? 1231 : 1237);
|
|
result = prime * result + ((this.type == null) ? 0 : this.type.hashCode());
|
|
return result;
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object obj)
|
|
{
|
|
if (this == obj) return true;
|
|
if (!super.equals(obj)) return false;
|
|
if (getClass() != obj.getClass()) return false;
|
|
Column other = (Column) obj;
|
|
if (this.nullable != other.nullable) return false;
|
|
if (this.type == null)
|
|
{
|
|
if (other.type != null) return false;
|
|
}
|
|
else if (!this.type.equals(other.type)) return false;
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
protected void doDiff(DbObject right, DiffContext ctx, Strength strength)
|
|
{
|
|
Differences differences = ctx.getDifferences();
|
|
Column rightColumn = (Column) right;
|
|
comparisonUtils.compareSimple(type, rightColumn.type, ctx);
|
|
comparisonUtils.compareSimple(nullable, rightColumn.nullable, ctx);
|
|
}
|
|
}
|