Skip to content

Commit

Permalink
Refactor expose codegen interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
minborg committed Mar 11, 2016
1 parent c361f53 commit aa2501f
Show file tree
Hide file tree
Showing 177 changed files with 892 additions and 772 deletions.
Expand Up @@ -14,16 +14,15 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package com.speedment.internal.core.code; package com.speedment.code;


import com.speedment.code.Translator; import com.speedment.codegen.lang.models.File;
import com.speedment.internal.codegen.lang.models.File;
import com.speedment.config.db.Project; import com.speedment.config.db.Project;
import com.speedment.config.db.trait.HasAlias; import com.speedment.config.db.trait.HasAlias;
import com.speedment.config.db.trait.HasMainInterface; import com.speedment.config.db.trait.HasMainInterface;
import com.speedment.config.db.trait.HasName; import com.speedment.config.db.trait.HasName;
import com.speedment.exception.SpeedmentException; import com.speedment.exception.SpeedmentException;
import com.speedment.internal.codegen.lang.models.ClassOrInterface; import com.speedment.codegen.lang.models.ClassOrInterface;
import static com.speedment.internal.codegen.util.Formatting.ucfirst; import static com.speedment.internal.codegen.util.Formatting.ucfirst;
import com.speedment.util.JavaLanguageNamer; import com.speedment.util.JavaLanguageNamer;
import static com.speedment.internal.util.document.DocumentUtil.relativeName; import static com.speedment.internal.util.document.DocumentUtil.relativeName;
Expand Down Expand Up @@ -237,7 +236,7 @@ default String fullyQualifiedTypeName(String subPath) {
* *
* @param subPath A prefix that will be added to the "class"-part of the * @param subPath A prefix that will be added to the "class"-part of the
* type name. * type name.
* @param subPath A sub-path to be added at the end of the 'package'-part of * @param filePrefix A sub-path to be added at the end of the 'package'-part of
* the qualified type name. This value can be {@code null} and in that * the qualified type name. This value can be {@code null} and in that
* case an ordinary fullyQualifiedTypeName will be returned. * case an ordinary fullyQualifiedTypeName will be returned.
* @return the fully qualified type name of the current document * @return the fully qualified type name of the current document
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/speedment/code/StandardTranslatorKey.java
Expand Up @@ -20,9 +20,9 @@
import com.speedment.config.db.Project; import com.speedment.config.db.Project;
import com.speedment.config.db.Table; import com.speedment.config.db.Table;
import com.speedment.internal.core.code.TranslatorKeyImpl; import com.speedment.internal.core.code.TranslatorKeyImpl;
import com.speedment.internal.codegen.lang.models.Class; import com.speedment.codegen.lang.models.Class;
import com.speedment.internal.codegen.lang.models.ClassOrInterface; import com.speedment.codegen.lang.models.ClassOrInterface;
import com.speedment.internal.codegen.lang.models.Interface; import com.speedment.codegen.lang.models.Interface;
import static com.speedment.util.StaticClassUtil.instanceNotAllowed; import static com.speedment.util.StaticClassUtil.instanceNotAllowed;
import java.util.stream.Stream; import java.util.stream.Stream;


Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/speedment/code/Translator.java
Expand Up @@ -32,10 +32,10 @@
import java.util.stream.Stream; import java.util.stream.Stream;
import com.speedment.config.db.trait.HasMainInterface; import com.speedment.config.db.trait.HasMainInterface;
import com.speedment.exception.SpeedmentException; import com.speedment.exception.SpeedmentException;
import com.speedment.internal.codegen.base.Generator; import com.speedment.codegen.base.Generator;
import com.speedment.internal.codegen.base.Meta; import com.speedment.codegen.base.Meta;
import com.speedment.internal.codegen.lang.models.ClassOrInterface; import com.speedment.codegen.lang.models.ClassOrInterface;
import com.speedment.internal.codegen.lang.models.File; import com.speedment.codegen.lang.models.File;
import java.util.Map; import java.util.Map;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
import java.util.function.BiFunction; import java.util.function.BiFunction;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/speedment/code/TranslatorConstructor.java
Expand Up @@ -19,8 +19,8 @@
import com.speedment.Speedment; import com.speedment.Speedment;
import com.speedment.annotation.Api; import com.speedment.annotation.Api;
import com.speedment.config.db.trait.HasMainInterface; import com.speedment.config.db.trait.HasMainInterface;
import com.speedment.internal.codegen.base.Generator; import com.speedment.codegen.base.Generator;
import com.speedment.internal.codegen.lang.models.ClassOrInterface; import com.speedment.codegen.lang.models.ClassOrInterface;


/** /**
* A functional interface that describes a constructor for a class that * A functional interface that describes a constructor for a class that
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/speedment/code/TranslatorDecorator.java
Expand Up @@ -19,8 +19,7 @@
import com.speedment.annotation.Api; import com.speedment.annotation.Api;
import com.speedment.config.db.trait.HasMainInterface; import com.speedment.config.db.trait.HasMainInterface;
import com.speedment.config.db.trait.HasName; import com.speedment.config.db.trait.HasName;
import com.speedment.internal.codegen.lang.models.ClassOrInterface; import com.speedment.codegen.lang.models.ClassOrInterface;
import com.speedment.internal.core.code.JavaClassTranslator;


/** /**
* This interface describes a functional reference to something that decorates * This interface describes a functional reference to something that decorates
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/speedment/code/TranslatorKey.java
Expand Up @@ -18,7 +18,7 @@


import com.speedment.annotation.Api; import com.speedment.annotation.Api;
import com.speedment.config.db.trait.HasMainInterface; import com.speedment.config.db.trait.HasMainInterface;
import com.speedment.internal.codegen.lang.models.ClassOrInterface; import com.speedment.codegen.lang.models.ClassOrInterface;


/** /**
* A key associated with a specific {@link Translator}. This is used to * A key associated with a specific {@link Translator}. This is used to
Expand Down
Expand Up @@ -14,7 +14,7 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package com.speedment.internal.codegen.base; package com.speedment.codegen.base;


import java.util.Optional; import java.util.Optional;


Expand Down
Expand Up @@ -14,7 +14,7 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package com.speedment.internal.codegen.base; package com.speedment.codegen.base;


import java.util.Collection; import java.util.Collection;
import java.util.Optional; import java.util.Optional;
Expand Down
131 changes: 131 additions & 0 deletions src/main/java/com/speedment/codegen/base/Meta.java
@@ -0,0 +1,131 @@
/**
*
* Copyright (c) 2006-2016, Speedment, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); You may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.speedment.codegen.base;

/**
* Meta information about the generation process.
*
* @author Emil Forslund
* @param <A> the model type
* @param <B> the result type
*/
public interface Meta<A, B> {

/**
* The model that was sent to the generator.
* @return the model
*/
A getModel();

/**
* The result that was produced by the generator.
* @return the model
*/
B getResult();

/**
* The transform that was used to produce the result.
* @return the transform
*/
Transform<A, B> getTransform();

/**
* The factory that created the transform.
* @return the factory
*/
TransformFactory getFactory();

/**
* The render stack that represents which generation processes is waiting
* for this result.
*
* @return the current render stack
*/
RenderStack getRenderStack();

// /**
// * Meta implementation.
// *
// * @param <A> the model type
// * @param <B> the result type
// */
// class Impl<A, B> implements Meta<A, B> {
//
// private A model;
// private B result;
// private Transform<A, B> transform;
// private TransformFactory factory;
// private RenderStack stack;
//
// Impl() {}
//
// @Override
// public B getResult() {
// return result;
// }
//
// protected Impl<A, B> setResult(B result) {
// this.result = result;
// return this;
// }
//
// @Override
// public Transform<A, B> getTransform() {
// return transform;
// }
//
// protected Impl<A, B> setTransform(Transform<A, B> view) {
// this.transform = view;
// return this;
// }
//
// @Override
// public TransformFactory getFactory() {
// return factory;
// }
//
// protected Impl<A, B> setFactory(TransformFactory factory) {
// this.factory = factory;
// return this;
// }
//
// @Override
// public A getModel() {
// return model;
// }
//
// public Impl<A, B> setModel(A model) {
// this.model = model;
// return this;
// }
//
// @Override
// public RenderStack getRenderStack() {
// return stack;
// }
//
// public Impl<A, B> setRenderStack(RenderStack stack) {
// this.stack = stack;
// return this;
// }
//
// @Override
// public String toString() {
// return "Impl{" + "model=" + model + ", result=" + result + ", transform=" + transform + ", factory=" + factory + ", stack=" + stack + '}';
// }
// }
}
Expand Up @@ -14,7 +14,7 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package com.speedment.internal.codegen.base; package com.speedment.codegen.base;


import java.util.stream.Stream; import java.util.stream.Stream;


Expand Down
Expand Up @@ -14,8 +14,9 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package com.speedment.internal.codegen.base; package com.speedment.codegen.base;


import com.speedment.codegen.base.Generator;
import java.util.Optional; import java.util.Optional;


/** /**
Expand Down
Expand Up @@ -14,7 +14,7 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package com.speedment.internal.codegen.base; package com.speedment.codegen.base;


import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
Expand Down Expand Up @@ -89,7 +89,7 @@ static <T> T create(Class<T> clazz) {
try { try {
return clazz.newInstance(); return clazz.newInstance();
} catch (InstantiationException | IllegalAccessException ex) { } catch (InstantiationException | IllegalAccessException ex) {
Logger.getLogger(DefaultTransformFactory.class.getName()).log(Level.SEVERE, Logger.getLogger(TransformFactory.class.getName()).log(Level.SEVERE,
"The class '" + clazz.getName() + "The class '" + clazz.getName() +
"' could not be instantiated using the default constructor. " + "' could not be instantiated using the default constructor. " +
"Make sure it is the correct class and that the default " + "Make sure it is the correct class and that the default " +
Expand Down
Expand Up @@ -14,7 +14,7 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package com.speedment.internal.codegen.lang.interfaces; package com.speedment.codegen.lang.interfaces;


import java.util.function.Consumer; import java.util.function.Consumer;


Expand Down
Expand Up @@ -14,7 +14,7 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package com.speedment.internal.codegen.lang.interfaces; package com.speedment.codegen.lang.interfaces;


/** /**
* Trait for code generator models that can be deep-copied. * Trait for code generator models that can be deep-copied.
Expand Down
Expand Up @@ -14,9 +14,9 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package com.speedment.internal.codegen.lang.interfaces; package com.speedment.codegen.lang.interfaces;


import com.speedment.internal.codegen.lang.models.AnnotationUsage; import com.speedment.codegen.lang.models.AnnotationUsage;
import java.util.List; import java.util.List;


/** /**
Expand Down
Expand Up @@ -14,9 +14,9 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package com.speedment.internal.codegen.lang.interfaces; package com.speedment.codegen.lang.interfaces;


import com.speedment.internal.codegen.lang.models.ClassOrInterface; import com.speedment.codegen.lang.models.ClassOrInterface;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;


Expand Down
Expand Up @@ -14,7 +14,7 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package com.speedment.internal.codegen.lang.interfaces; package com.speedment.codegen.lang.interfaces;


import static com.speedment.util.NullUtil.requireNonNulls; import static com.speedment.util.NullUtil.requireNonNulls;
import java.util.Collections; import java.util.Collections;
Expand Down
Expand Up @@ -14,7 +14,7 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package com.speedment.internal.codegen.lang.interfaces; package com.speedment.codegen.lang.interfaces;


import java.util.Optional; import java.util.Optional;


Expand Down
Expand Up @@ -14,9 +14,9 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package com.speedment.internal.codegen.lang.interfaces; package com.speedment.codegen.lang.interfaces;


import com.speedment.internal.codegen.lang.models.Constructor; import com.speedment.codegen.lang.models.Constructor;
import java.util.List; import java.util.List;


/** /**
Expand Down
Expand Up @@ -14,9 +14,9 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package com.speedment.internal.codegen.lang.interfaces; package com.speedment.codegen.lang.interfaces;


import com.speedment.internal.codegen.lang.models.Field; import com.speedment.codegen.lang.models.Field;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;


Expand Down
Expand Up @@ -14,9 +14,9 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package com.speedment.internal.codegen.lang.interfaces; package com.speedment.codegen.lang.interfaces;


import com.speedment.internal.codegen.lang.models.Generic; import com.speedment.codegen.lang.models.Generic;
import java.util.List; import java.util.List;


/** /**
Expand Down
Expand Up @@ -14,9 +14,9 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package com.speedment.internal.codegen.lang.interfaces; package com.speedment.codegen.lang.interfaces;


import com.speedment.internal.codegen.lang.models.Type; import com.speedment.codegen.lang.models.Type;
import java.util.List; import java.util.List;


/** /**
Expand Down
Expand Up @@ -14,9 +14,9 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package com.speedment.internal.codegen.lang.interfaces; package com.speedment.codegen.lang.interfaces;


import com.speedment.internal.codegen.lang.models.Import; import com.speedment.codegen.lang.models.Import;
import java.util.List; import java.util.List;


/** /**
Expand Down

0 comments on commit aa2501f

Please sign in to comment.