@@ -0,0 +1,2149 @@
+/*%0A * Copyright (C) 2004-2008  exedio GmbH (www.exedio.com)%0A *%0A * This library is free software; you can redistribute it and/or%0A * modify it under the terms of the GNU Lesser General Public%0A * License as published by the Free Software Foundation; either%0A * version 2.1 of the License, or (at your option) any later version.%0A *%0A * This library is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU%0A * Lesser General Public License for more details.%0A *%0A * You should have received a copy of the GNU Lesser General Public%0A * License along with this library; if not, write to the Free Software%0A * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA%0A */%0A%0Apackage com.exedio.cope;%0A%0Apublic final class TypeColumn extends StringColumn%0A%7B%0A%09private final String itemColumnProtectedID;%0A%09%0A%09TypeColumn(%0A%09%09%09final Table table,%0A%09%09%09final ItemColumn itemColumn,%0A%09%09%09final boolean optional,%0A%09%09%09final String%5B%5D allowedValues)%0A%09%7B%0A%09%09super(table, null, itemColumn.id + %22Type%22/* not equal to %22name%22! */, optional, allowedValues);%0A%09%09this.itemColumnProtectedID = itemColumn.protectedID;%0A%09%7D%0A%09%0A%09@Override%0A%09String getCheckConstraintIfNotNull()%0A%09%7B%0A%09%09final String superResult = super.getCheckConstraintIfNotNull();%0A%09%09if(!optional)%0A%09%09%09return superResult;%0A%09%09%0A%09%09assert superResult!=null;%0A%09%09return %22(%22 + superResult + %22) AND (%22 + itemColumnProtectedID + %22 IS NOT NULL)%22;%0A%09%7D%0A%09%0A%09@Override%0A%09String getCheckConstraintIfNull()%0A%09%7B%0A%09%09if(super.getCheckConstraintIfNull()!=null)%0A%09%09%09throw new RuntimeException(); // not implemented%0A%09%09%0A%09%09return itemColumnProtectedID + %22 IS NULL%22;%0A%09%7D%0A%09%0A%09/*@Override%0A%09String getCheckConstraintIgnoringMandatory()%0A%09%7B%0A%09%09final String superResult = super.getCheckConstraintIgnoringMandatory();%0A%09%09if(!optional)%0A%09%09%09return superResult;%0A%09%09%0A%09%09assert superResult!=null;%0A%09%09return%0A%09%09%09%22(%22 + superResult + %22) AND (%22 +%0A%09%09%09%09%22((%22 + protectedID + %22 IS NULL) AND (%22     + itemColumnProtectedID + %22 IS NULL))%22 +%0A%09%09%09%09%22 OR %22 +%0A%09%09%09%09%22((%22 + protectedID + %22 IS NOT NULL) AND (%22 + itemColumnProtectedID + %22 IS NOT NULL))%22 +%0A%09%09%09%22)%22;%0A%09%7D*/%0A%7D%0A

test properly for consistence between foreign key column and type column regarding null/notNull (2)