01: /*
02: * Copyright 2006-2007 Pentaho Corporation. All rights reserved.
03: * This software was developed by Pentaho Corporation and is provided under the terms
04: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
05: * this file except in compliance with the license. If you need a copy of the license,
06: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt.
07: *
08: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
09: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
10: * the license for the specific language governing your rights and limitations.
11: *
12: * Additional Contributor(s): Martin Schmid gridvision engineering GmbH
13: */
14: package org.pentaho.reportdesigner.lib.client.commands;
15:
16: import org.jetbrains.annotations.NonNls;
17: import org.jetbrains.annotations.NotNull;
18: import org.jetbrains.annotations.Nullable;
19:
20: /**
21: * User: Martin
22: * Date: 19.05.2005
23: * Time: 12:49:43
24: */
25: public class CommandConstraint {
26:
27: public enum ConstraintType {
28: @NotNull
29: FIRST, @NotNull
30: LAST, @NotNull
31: BEFORE, @NotNull
32: AFTER
33: }
34:
35: @NotNull
36: public static final CommandConstraint FIRST = new CommandConstraint(
37: ConstraintType.FIRST, "");
38: @NotNull
39: public static final CommandConstraint LAST = new CommandConstraint(
40: ConstraintType.LAST, "");
41:
42: @NotNull
43: private ConstraintType constraintType;
44: @NotNull
45: private String reference;
46:
47: public CommandConstraint(@NotNull
48: ConstraintType constraintType, @NotNull
49: @NonNls
50: String reference) {
51: //noinspection ConstantConditions
52: if (constraintType == null) {
53: throw new IllegalArgumentException(
54: "constrainedType must not be null");
55: }
56: //noinspection ConstantConditions
57: if (reference == null) {
58: throw new IllegalArgumentException(
59: "reference must not be null");
60: }
61:
62: this .constraintType = constraintType;
63: this .reference = reference;
64: }
65:
66: @NotNull
67: public ConstraintType getConstraintType() {
68: return constraintType;
69: }
70:
71: @NotNull
72: public String getReference() {
73: return reference;
74: }
75:
76: public boolean equals(@Nullable
77: Object o) {
78: if (this == o)
79: return true;
80: if (!(o instanceof CommandConstraint))
81: return false;
82:
83: final CommandConstraint commandConstraint = (CommandConstraint) o;
84:
85: if (!constraintType.equals(commandConstraint.constraintType))
86: return false;
87: return reference.equals(commandConstraint.reference);
88: }
89:
90: public int hashCode() {
91: int result;
92: result = constraintType.hashCode();
93: result = 29 * result + reference.hashCode();
94: return result;
95: }
96: }
|