1 19 20 package org.netbeans.modules.j2ee.persistence.wizard.fromdb; 21 22 import java.util.Set ; 23 import org.netbeans.modules.j2ee.persistence.wizard.Util; 24 import org.openide.util.NbBundle; 25 26 31 public abstract class Table implements Comparable <Table> { 32 33 private final String name; 34 private final boolean join; 35 private final DisabledReason disabledReason; 36 37 public Table(String name, boolean join, DisabledReason disabledReason) { 38 this.name = name; 39 this.join = join; 40 this.disabledReason = disabledReason; 41 } 42 43 public boolean equals(Object that) { 44 if (that instanceof Table) { 45 return compareTo((Table)that) == 0; 46 } else { 47 return false; 48 } 49 } 50 51 public int compareTo(Table that) { 52 if (that == null) { 53 return 1; 54 } 55 return this.getName().compareTo(that.getName()); 56 } 57 58 61 public String getName() { 62 return name; 63 } 64 65 68 public boolean isJoin() { 69 return join; 70 } 71 72 76 public DisabledReason getDisabledReason() { 77 return disabledReason; 78 } 79 80 84 public boolean isDisabled() { 85 return disabledReason != null; 86 } 87 88 public String toString() { 89 return "TableItem[name='" + name + "']"; } 91 92 95 public abstract Set <Table> getReferencedTables(); 96 97 100 public abstract Set <Table> getReferencedByTables(); 101 102 105 public abstract Set <Table> getJoinTables(); 106 107 112 public static class DisabledReason { 113 114 private final String displayName; 115 private final String description; 116 117 public DisabledReason(String displayName, String description) { 118 this.displayName = displayName; 119 this.description = description; 120 } 121 122 public String getDisplayName() { 123 return displayName; 124 } 125 126 public String getDescription() { 127 return description; 128 } 129 } 130 131 135 public static final class ExistingDisabledReason extends DisabledReason { 136 137 private String fqClassName; 138 139 public ExistingDisabledReason(String fqClassName) { 140 super(NbBundle.getMessage(Table.class, "LBL_AlreadyMapped", Util.getClassName(fqClassName)), 141 NbBundle.getMessage(Table.class, "LBL_AlreadyMappedDescription", fqClassName)); 142 this.fqClassName = fqClassName; 143 } 144 145 public String getFQClassName() { 146 return fqClassName; 147 } 148 } 149 150 154 public static final class NoPrimaryKeyDisabledReason extends DisabledReason { 155 156 public NoPrimaryKeyDisabledReason() { 157 super(NbBundle.getMessage(Table.class, "LBL_NoPrimaryKey"), NbBundle.getMessage(Table.class, "LBL_NoPrimaryKeyDescription")); 158 } 159 } 160 } 161 | Popular Tags |