Skip to content
Permalink
Browse files

[core] Fix row classes naming: move Row1 from acolyte.Row.Row1 up to …

…acolyte.Row1.
  • Loading branch information
cchantep
cchantep committed Jan 9, 2014
1 parent 4c8fcb8 commit a447ac9436f4c020e6bb48a58f5e8d6558da9b75
Showing with 89 additions and 79 deletions.
  1. +0 −79 core/src/main/java/acolyte/Row.java
  2. +89 −0 core/src/main/java/acolyte/Row1.java
@@ -1,12 +1,7 @@
package acolyte;

import java.util.Collections;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.EqualsBuilder;

/**
* Row marker interface
*/
@@ -28,78 +23,4 @@
*/
public List<Object> cells() { return null; }
} // end of class Nothing

// --- Inner classes ---

/**
* Row with 1 cell.
*/
public static final class Row1<A> implements Row {
public final A _1;
public final List<Object> cells;

// --- Constructors ---

/**
* Copy constructor.
*
* @param c1 Value for cell #1
*/
protected Row1(final A c1) {
this._1 = c1;

final ArrayList<Object> cs = new ArrayList<Object>(1);

cs.add(this._1);

this.cells = Collections.unmodifiableList(cs);
} // end of <init>

// ---

/**
* {@inheritDoc}
*/
public List<Object> cells() {
return this.cells;
} // end of cells

// --- Object support ---

/**
* {@inheritDoc}
*/
public int hashCode() {
return new HashCodeBuilder(3, 7).
append(this._1).
toHashCode();

} // end of hashCode

/**
* {@inheritDoc}
*/
public boolean equals(final Object o) {
if (o == null || !(o instanceof Row1)) {
return false;
} // end of if

// ---

@SuppressWarnings("unchecked")
final Row1<A> other = (Row1<A>) o;

return new EqualsBuilder().
append(this._1, other._1).
isEquals();

} // end of equals

/**
* {@inheritDoc}
*/
public String toString() {
return String.format("Row1(%s)", this._1);
} // end of toString
} // end of class Row1
} // end of interface Row
@@ -0,0 +1,89 @@
package acolyte;

import java.util.Collections;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.EqualsBuilder;

/**
* Row with 1 cell.
*/
public final class Row1<A> implements Row {
// --- Properties ---

/**
* Value for cell #1
*/
public final A _1;

/**
* Cell list
*/
public final List<Object> cells;

// --- Constructors ---

/**
* Copy constructor.
*
* @param c1 Value for cell #1
*/
protected Row1(final A c1) {
this._1 = c1;

final ArrayList<Object> cs = new ArrayList<Object>(1);

cs.add(this._1);

this.cells = Collections.unmodifiableList(cs);
} // end of <init>

// ---

/**
* {@inheritDoc}
*/
public List<Object> cells() {
return this.cells;
} // end of cells

// --- Object support ---

/**
* {@inheritDoc}
*/
public int hashCode() {
return new HashCodeBuilder(3, 7).
append(this._1).
toHashCode();

} // end of hashCode

/**
* {@inheritDoc}
*/
public boolean equals(final Object o) {
if (o == null || !(o instanceof Row1)) {
return false;
} // end of if

// ---

@SuppressWarnings("unchecked")
final Row1<A> other = (Row1<A>) o;

return new EqualsBuilder().
append(this._1, other._1).
isEquals();

} // end of equals

/**
* {@inheritDoc}
*/
public String toString() {
return String.format("Row1(%s)", this._1);
} // end of toString
} // end of class Row1

0 comments on commit a447ac9

Please sign in to comment.
You can’t perform that action at this time.