protected boolean useEquals() { return true; } /** * Returns whether two objects are equal using the {@link #useEquals appropriate} comparison mechanism. * @return whether two objects are equal. */ protected boolean equalObjects(Object firstObject, Object secondObject) { return useEquals() && firstObject != null ? firstObject.equals(secondObject) : firstObject == secondObject; } /** * Returns whether <code>null</code> is a valid object for the list. * The default is to return <code>true</code>, but clients can override this to exclude <code>null</code>. * @return whether <code>null</code> is a valid object for the list. */ protected boolean canContainNull() { return true; } /** * Returns whether objects are constrained to appear at most once in the list. * The default is to return <code>false</code>, but clients can override this to ensure uniqueness of contents. * The performance impact is significant: operations such as <code>add</code> are O(n) as a result requiring uniqueness. * @return whether objects are constrained to appear at most once in the list. */ protected boolean isUnique() { return false; } /** * Validates a new content object and returns the validated object. * This implementation checks for null, if {@link #canContainNull necessary} and returns the argument object. * Clients may throw additional types of runtime exceptions * in order to handle constraint violations. * @param index the position of the new content. * @param object the new content. * @return the validated content. * @exception IllegalArgumentException if a constraint prevents the object from being added. */ protected E validate(int index, E object) { if (!canContainNull() && object == null) { throw new IllegalArgumentException("The 'no null' constraint is violated"); } return object;
protected boolean useEquals() { return true; } /** * Returns whether two objects are equal using the {@link #useEquals appropriate} comparison mechanism. * @return whether two objects are equal. */ protected boolean equalObjects(Object firstObject, Object secondObject) { return useEquals() && firstObject != null ? firstObject.equals(secondObject) : firstObject == secondObject; } /** * Returns whether <code>null</code> is a valid object for the list. * The default is to return <code>true</code>, but clients can override this to exclude <code>null</code>. * @return whether <code>null</code> is a valid object for the list. */ protected boolean canContainNull() { return true; } /** * Returns whether objects are constrained to appear at most once in the list. * The default is to return <code>false</code>, but clients can override this to ensure uniqueness of contents. * The performance impact is significant: operations such as <code>add</code> are O(n) as a result requiring uniqueness. * @return whether objects are constrained to appear at most once in the list. */ protected boolean isUnique() { return false; } /** * Validates a new content object and returns the validated object. * This implementation checks for null, if {@link #canContainNull necessary} and returns the argument object. * Clients may throw additional types of runtime exceptions * in order to handle constraint violations. * @param index the position of the new content. * @param object the new content. * @return the validated content. * @exception IllegalArgumentException if a constraint prevents the object from being added. */ protected E validate(int index, E object) { if (!canContainNull() && object == null) { throw new IllegalArgumentException("The 'no null' constraint is violated"); } return object;
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/common/util/BasicEList.java File path: /emf-2.4.1/src/org/eclipse/emf/common/util/DelegatingEList.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
protected boolean useEquals()
1
protected boolean useEquals()
2
  {
2
  {
3
    return true;
3
    return true;
4
  }
4
  }
5
  /**
5
  /**
6
   * Returns whether two objects are equal using the {@link #useEquals appropriate} comparison mechanism.
6
   * Returns whether two objects are equal using the {@link #useEquals appropriate} comparison mechanism.
7
   * @return whether two objects are equal.
7
   * @return whether two objects are equal.
8
   */
8
   */
9
  protected boolean equalObjects(Object firstObject, Object secondObject)
9
  protected boolean equalObjects(Object firstObject, Object secondObject)
10
  {
10
  {
11
    return
11
    return
12
      useEquals() && firstObject != null ?
12
      useEquals() && firstObject != null ?
13
        firstObject.equals(secondObject) :
13
        firstObject.equals(secondObject) :
14
        firstObject == secondObject;
14
        firstObject == secondObject;
15
  }
15
  }
16
  /**
16
  /**
17
   * Returns whether <code>null</code> is a valid object for the list.
17
   * Returns whether <code>null</code> is a valid object for the list.
18
   * The default is to return <code>true</code>, but clients can override this to exclude <code>null</code>.
18
   * The default is to return <code>true</code>, but clients can override this to exclude <code>null</code>.
19
   * @return whether <code>null</code> is a valid object for the list.
19
   * @return whether <code>null</code> is a valid object for the list.
20
   */
20
   */
21
  protected boolean canContainNull()
21
  protected boolean canContainNull()
22
  {
22
  {
23
    return true;
23
    return true;
24
  }
24
  }
25
  /**
25
  /**
26
   * Returns whether objects are constrained to appear at most once in the list.
26
   * Returns whether objects are constrained to appear at most once in the list.
27
   * The default is to return <code>false</code>, but clients can override this to ensure uniqueness of contents.
27
   * The default is to return <code>false</code>, but clients can override this to ensure uniqueness of contents.
28
   * The performance impact is significant: operations such as <code>add</code> are O(n) as a result requiring uniqueness.
28
   * The performance impact is significant: operations such as <code>add</code> are O(n) as a result requiring uniqueness.
29
   * @return whether objects are constrained to appear at most once in the list.
29
   * @return whether objects are constrained to appear at most once in the list.
30
   */
30
   */
31
  protected boolean isUnique()
31
  protected boolean isUnique()
32
  {
32
  {
33
    return false;
33
    return false;
34
  }
34
  }
35
  /**
35
  /**
36
   * Validates a new content object and returns the validated object.
36
   * Validates a new content object and returns the validated object.
37
   * This implementation checks for null, if {@link #canContainNull necessary} and returns the argument object.
37
   * This implementation checks for null, if {@link #canContainNull necessary} and returns the argument object.
38
   * Clients may throw additional types of runtime exceptions 
38
   * Clients may throw additional types of runtime exceptions 
39
   * in order to handle constraint violations.
39
   * in order to handle constraint violations.
40
   * @param index the position of the new content.
40
   * @param index the position of the new content.
41
   * @param object the new content.
41
   * @param object the new content.
42
   * @return the validated content.
42
   * @return the validated content.
43
   * @exception IllegalArgumentException if a constraint prevents the object from being added.
43
   * @exception IllegalArgumentException if a constraint prevents the object from being added.
44
   */
44
   */
45
  protected E validate(int index, E object)
45
  protected E validate(int index, E object)
46
  {
46
  {
47
    if (!canContainNull() && object == null)
47
    if (!canContainNull() && object == null)
48
    {
48
    {
49
      throw new IllegalArgumentException("The 'no null' constraint is violated");
49
      throw new IllegalArgumentException("The 'no null' constraint is violated");
50
    }
50
    }
51
    return object;
51
    return object;
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0