Skip to content

Commit

Permalink
[FLINK-8422] [core] Checkstyle for org.apache.flink.api.java.tuple
Browse files Browse the repository at this point in the history
Update TupleGenerator for Flink's checkstyle and rebuild Tuple and
TupleBuilder classes.

This closes #5292.
  • Loading branch information
greghogan authored and zentol committed Jan 31, 2018
1 parent 91cf60b commit 36b2325
Show file tree
Hide file tree
Showing 56 changed files with 2,217 additions and 775 deletions.
34 changes: 17 additions & 17 deletions flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@
* which may all be of different types. Because Tuples are strongly typed, each distinct
* tuple length is represented by its own class. Tuples exists with up to 25 fields and
* are described in the classes {@link Tuple1} to {@link Tuple25}.
* <p>
* The fields in the tuples may be accessed directly a public fields, or via position (zero indexed)
*
* <p>The fields in the tuples may be accessed directly a public fields, or via position (zero indexed)
* {@link #getField(int)}.
* <p>
* Tuples are in principle serializable. However, they may contain non-serializable fields,
*
* <p>Tuples are in principle serializable. However, they may contain non-serializable fields,
* in which case serialization will fail.
*/
@Public
public abstract class Tuple implements java.io.Serializable {

private static final long serialVersionUID = 1L;

public static final int MAX_ARITY = 25;


/**
* Gets the field at the specified position.
*
Expand All @@ -50,11 +50,11 @@ public abstract class Tuple implements java.io.Serializable {
* @throws IndexOutOfBoundsException Thrown, if the position is negative, or equal to, or larger than the number of fields.
*/
public abstract <T> T getField(int pos);

/**
* Gets the field at the specified position, throws NullFieldException if the field is null. Used for comparing key fields.
*
* @param pos The position of the field, zero indexed.
*
* @param pos The position of the field, zero indexed.
* @return The field at the specified position.
* @throws IndexOutOfBoundsException Thrown, if the position is negative, or equal to, or larger than the number of fields.
* @throws NullFieldException Thrown, if the field at pos is null.
Expand Down Expand Up @@ -91,11 +91,11 @@ public <T> T getFieldNotNull(int pos){
public abstract <T extends Tuple> T copy();

// --------------------------------------------------------------------------------------------

/**
* Gets the class corresponding to the tuple of the given arity (dimensions). For
* example, {@code getTupleClass(3)} will return the {@code Tuple3.class}.
*
*
* @param arity The arity of the tuple class to get.
* @return The tuple class with the given arity.
*/
Expand All @@ -106,12 +106,12 @@ public static Class<? extends Tuple> getTupleClass(int arity) {
}
return (Class<? extends Tuple>) CLASSES[arity];
}
// --------------------------------------------------------------------------------------------

// --------------------------------------------------------------------------------------------
// The following lines are generated.
// --------------------------------------------------------------------------------------------
// BEGIN_OF_TUPLE_DEPENDENT_CODE

// BEGIN_OF_TUPLE_DEPENDENT_CODE
// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
private static final Class<?>[] CLASSES = new Class<?>[] {
Tuple0.class, Tuple1.class, Tuple2.class, Tuple3.class, Tuple4.class, Tuple5.class, Tuple6.class, Tuple7.class, Tuple8.class, Tuple9.class, Tuple10.class, Tuple11.class, Tuple12.class, Tuple13.class, Tuple14.class, Tuple15.class, Tuple16.class, Tuple17.class, Tuple18.class, Tuple19.class, Tuple20.class, Tuple21.class, Tuple22.class, Tuple23.class, Tuple24.class, Tuple25.class
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
Expand All @@ -15,6 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.flink.api.java.tuple;

import org.apache.flink.annotation.Public;
Expand All @@ -23,21 +24,21 @@

/**
* A tuple with 0 fields.
*
*
* <p>The Tuple0 is a soft singleton, i.e., there is a "singleton" instance, but it does
* not prevent creation of additional instances.</p>
*
*
* @see Tuple
*/
@Public
public class Tuple0 extends Tuple {
private static final long serialVersionUID = 1L;

/** An immutable reusable Tuple0 instance */
// an immutable reusable Tuple0 instance
public static final Tuple0 INSTANCE = new Tuple0();

// ------------------------------------------------------------------------

@Override
public int getArity() {
return 0;
Expand Down Expand Up @@ -68,8 +69,8 @@ public Tuple0 copy(){
// -------------------------------------------------------------------------------------------------

/**
* Creates a string representation of the tuple in the form "()"
*
* Creates a string representation of the tuple in the form "()".
*
* @return The string representation of the tuple.
*/
@Override
Expand All @@ -78,8 +79,8 @@ public String toString() {
}

/**
* Deep equality for tuples by calling equals() on the tuple members
*
* Deep equality for tuples by calling equals() on the tuple members.
*
* @param o
* the object checked for equality
* @return true if this is equal to o.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@
* limitations under the License.
*/


// --------------------------------------------------------------
// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
// --------------------------------------------------------------


package org.apache.flink.api.java.tuple;

import org.apache.flink.annotation.Public;
Expand Down Expand Up @@ -70,7 +68,9 @@ public Tuple1(T0 value0) {
}

@Override
public int getArity() { return 1; }
public int getArity() {
return 1;
}

@Override
@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -119,17 +119,23 @@ public String toString() {
}

/**
* Deep equality for tuples by calling equals() on the tuple members
* Deep equality for tuples by calling equals() on the tuple members.
* @param o the object checked for equality
* @return true if this is equal to o.
*/
@Override
public boolean equals(Object o) {
if(this == o) { return true; }
if (!(o instanceof Tuple1)) { return false; }
if (this == o) {
return true;
}
if (!(o instanceof Tuple1)) {
return false;
}
@SuppressWarnings("rawtypes")
Tuple1 tuple = (Tuple1) o;
if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) {
return false;
}
return true;
}

Expand All @@ -145,8 +151,8 @@ public int hashCode() {
*/
@Override
@SuppressWarnings("unchecked")
public Tuple1<T0> copy(){
return new Tuple1<T0>(this.f0);
public Tuple1<T0> copy() {
return new Tuple1<>(this.f0);
}

/**
Expand All @@ -158,6 +164,6 @@ public Tuple1<T0> copy(){
* {@code new Tuple3<Integer, Double, String>(n, x, s)}
*/
public static <T0> Tuple1<T0> of(T0 value0) {
return new Tuple1<T0>(value0);
return new Tuple1<>(value0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@
* limitations under the License.
*/


// --------------------------------------------------------------
// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
// --------------------------------------------------------------


package org.apache.flink.api.java.tuple;

import org.apache.flink.annotation.Public;
Expand Down Expand Up @@ -115,7 +113,9 @@ public Tuple10(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5,
}

@Override
public int getArity() { return 10; }
public int getArity() {
return 10;
}

@Override
@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -227,26 +227,50 @@ public String toString() {
}

/**
* Deep equality for tuples by calling equals() on the tuple members
* Deep equality for tuples by calling equals() on the tuple members.
* @param o the object checked for equality
* @return true if this is equal to o.
*/
@Override
public boolean equals(Object o) {
if(this == o) { return true; }
if (!(o instanceof Tuple10)) { return false; }
if (this == o) {
return true;
}
if (!(o instanceof Tuple10)) {
return false;
}
@SuppressWarnings("rawtypes")
Tuple10 tuple = (Tuple10) o;
if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) { return false; }
if (f9 != null ? !f9.equals(tuple.f9) : tuple.f9 != null) { return false; }
if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) {
return false;
}
if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) {
return false;
}
if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) {
return false;
}
if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) {
return false;
}
if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) {
return false;
}
if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) {
return false;
}
if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) {
return false;
}
if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) {
return false;
}
if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) {
return false;
}
if (f9 != null ? !f9.equals(tuple.f9) : tuple.f9 != null) {
return false;
}
return true;
}

Expand All @@ -271,8 +295,8 @@ public int hashCode() {
*/
@Override
@SuppressWarnings("unchecked")
public Tuple10<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9> copy(){
return new Tuple10<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9>(this.f0,
public Tuple10<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> copy() {
return new Tuple10<>(this.f0,
this.f1,
this.f2,
this.f3,
Expand All @@ -292,7 +316,16 @@ public Tuple10<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9> copy(){
* instead of
* {@code new Tuple3<Integer, Double, String>(n, x, s)}
*/
public static <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9> Tuple10<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9) {
return new Tuple10<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9);
public static <T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> Tuple10<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9) {
return new Tuple10<>(value0,
value1,
value2,
value3,
value4,
value5,
value6,
value7,
value8,
value9);
}
}
Loading

0 comments on commit 36b2325

Please sign in to comment.