1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  
17  package org.apache.commons.math4.legacy.genetics;
18  
19  import java.util.Arrays;
20  import java.util.List;
21  
22  
23  
24  
25  public class DummyListChromosome extends AbstractListChromosome<Integer> {
26      public DummyListChromosome(final Integer[] representation) {
27          super(representation);
28      }
29  
30      public DummyListChromosome(final List<Integer> representation) {
31          super(representation);
32      }
33  
34      @Override
35      public double fitness() {
36          
37          return 0;
38      }
39  
40      @Override
41      protected void checkValidity(final List<Integer> chromosomeRepresentation) throws InvalidRepresentationException {
42          
43      }
44  
45      @Override
46      public AbstractListChromosome<Integer> newFixedLengthChromosome(final List<Integer> chromosomeRepresentation) {
47          return new DummyListChromosome(chromosomeRepresentation);
48      }
49  
50      @Override
51      public int hashCode() {
52          final int prime = 31;
53          int result = 1;
54          result = prime * result + (getRepresentation() == null ? 0 : getRepresentation().hashCode());
55          return result;
56      }
57  
58      @Override
59      public boolean equals(final Object obj) {
60          if (this == obj) {
61              return true;
62          }
63          if (obj == null) {
64              return false;
65          }
66          if (!(obj instanceof DummyListChromosome)) {
67              return false;
68          }
69          final DummyListChromosome other = (DummyListChromosome) obj;
70          if (getRepresentation() == null) {
71              if (other.getRepresentation() != null) {
72                  return false;
73              }
74          }
75          final Integer[] rep = getRepresentation().toArray(new Integer[getRepresentation().size()]);
76          final Integer[] otherRep = other.getRepresentation().toArray(new Integer[other.getRepresentation().size()]);
77          return Arrays.equals(rep, otherRep);
78      }
79  }