Skip to content

Commit

Permalink
runtime-config: #465 Add missing trait to Column interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyknic committed May 25, 2017
1 parent 8589941 commit f6fa9c8
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 29 deletions.
Expand Up @@ -18,19 +18,7 @@


import com.speedment.runtime.config.mutator.ColumnMutator; import com.speedment.runtime.config.mutator.ColumnMutator;
import com.speedment.runtime.config.mutator.DocumentMutator; import com.speedment.runtime.config.mutator.DocumentMutator;
import com.speedment.runtime.config.trait.HasAlias; import com.speedment.runtime.config.trait.*;
import com.speedment.runtime.config.trait.HasColumnSize;
import com.speedment.runtime.config.trait.HasDecimalDigits;
import com.speedment.runtime.config.trait.HasEnabled;
import com.speedment.runtime.config.trait.HasId;
import com.speedment.runtime.config.trait.HasMainInterface;
import com.speedment.runtime.config.trait.HasMutator;
import com.speedment.runtime.config.trait.HasName;
import com.speedment.runtime.config.trait.HasNullable;
import com.speedment.runtime.config.trait.HasOrdinalPosition;
import com.speedment.runtime.config.trait.HasParent;
import com.speedment.runtime.config.trait.HasTypeMapper;
import java.util.Optional;


/** /**
* A typed {@link Document} that represents a column in the database. A * A typed {@link Document} that represents a column in the database. A
Expand All @@ -52,33 +40,21 @@ public interface Column extends
HasDecimalDigits, HasDecimalDigits,
HasColumnSize, HasColumnSize,
HasMainInterface, HasMainInterface,
HasEnumConstants,
HasMutator<ColumnMutator<? extends Column>> { HasMutator<ColumnMutator<? extends Column>> {


String AUTO_INCREMENT = "autoIncrement", String AUTO_INCREMENT = "autoIncrement";
ENUM_CONSTANTS = "enumConstants";


/** /**
* Returns whether or not this column will auto increment when new values * Returns whether or not this column will auto increment when new values
* are added to the table. * are added to the table.
* *
* @return <code>true</code> if the column auto increments, else * @return {@code true} if the column auto increments, else {@code false}
* <code>false</code>
*/ */
default boolean isAutoIncrement() { default boolean isAutoIncrement() {
return getAsBoolean(AUTO_INCREMENT).orElse(false); return getAsBoolean(AUTO_INCREMENT).orElse(false);
} }


/**
* Returns a comma separated string of the possible values that this column
* may have. If the list of potential values are not constrained, an empty
* optional is returned.
*
* @return list of constant values separated by commas or empty
*/
default Optional<String> getEnumConstants() {
return getAsString(ENUM_CONSTANTS);
}

@Override @Override
default Class<Column> mainInterface() { default Class<Column> mainInterface() {
return Column.class; return Column.class;
Expand Down
@@ -0,0 +1,33 @@
package com.speedment.runtime.config.trait;

import com.speedment.runtime.config.Document;

import java.util.Optional;

/**
* A trait for {@link Document documents} that implement the
* {@link #getEnumConstants()} method.
*
* @author Emil Forslund
* @since 3.0.10
*/
public interface HasEnumConstants extends Document {

/**
* The attribute for the 'enumConstants' field in the JSON Configuration
* file.
*/
String ENUM_CONSTANTS = "enumConstants";

/**
* Returns a comma separated string of the possible values that this column
* may have. If the list of potential values are not constrained, an empty
* optional is returned.
*
* @return list of constant values separated by commas or empty
*/
default Optional<String> getEnumConstants() {
return getAsString(ENUM_CONSTANTS);
}

}
Expand Up @@ -26,7 +26,6 @@
* @author Per Minborg * @author Per Minborg
* @since 2.3.0 * @since 2.3.0
*/ */

public interface HasMainInterface extends Document { public interface HasMainInterface extends Document {


/** /**
Expand Down

0 comments on commit f6fa9c8

Please sign in to comment.