View Javadoc

1   /*
2      Copyright 2008 Ramon Servadei
3   
4      Licensed under the Apache License, Version 2.0 (the "License");
5      you may not use this file except in compliance with the License.
6      You may obtain a copy of the License at
7   
8          http://www.apache.org/licenses/LICENSE-2.0
9   
10     Unless required by applicable law or agreed to in writing, software
11     distributed under the License is distributed on an "AS IS" BASIS,
12     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13     See the License for the specific language governing permissions and
14     limitations under the License.
15   */
16  package fulmine.model.container.events;
17  
18  import fulmine.event.AbstractEvent;
19  import fulmine.model.container.IContainer;
20  import fulmine.model.field.IField;
21  
22  /**
23   * Base-class for events associated with {@link IField} instances being added or
24   * removed from an {@link IContainer}. The source of the event is the
25   * {@link IContainer}.
26   * 
27   * @author Ramon Servadei
28   */
29  public abstract class AbstractContainerFieldEvent extends AbstractEvent
30  {
31      /** The field for the event */
32      private final IField field;
33  
34      /**
35       * Standard constructor with the field
36       * 
37       * @param field
38       *            the field for the event
39       */
40      protected AbstractContainerFieldEvent(IContainer source, IField field)
41      {
42          super();
43          setSource(source);
44          this.field = field;
45      }
46  
47      /**
48       * Get the field for the event.
49       * 
50       * @return the field for the event
51       */
52      public final IField getField()
53      {
54          return this.field;
55      }
56  
57      @Override
58      protected String getAdditionalToString()
59      {
60          return getField().toString();
61      }
62  
63  }