Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ROASTER-1: Java Statement Fluent Model #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions api/src/main/java/org/jboss/forge/roaster/model/Block.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright 2014 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Eclipse Public License version 1.0, available at
* http://www.eclipse.org/legal/epl-v10.html
*/

package org.jboss.forge.roaster.model;

import org.jboss.forge.roaster.Origin;
import org.jboss.forge.roaster.model.source.BlockHolder;

/**
* Represent a block, a sequence of statements possibly including other blocks
*/
public interface Block<O extends JavaType<O>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing javadoc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

On Sat, Jul 25, 2015 at 11:48 PM, George Gastaldi notifications@github.com
wrote:

In api/src/main/java/org/jboss/forge/roaster/model/Block.java
#27 (comment):

@@ -0,0 +1,18 @@
+/*

  • * Copyright 2014 Red Hat, Inc. and/or its affiliates.
  • * Licensed under the Eclipse Public License version 1.0, available at
  • * http://www.eclipse.org/legal/epl-v10.html
  • */
    +
    +package org.jboss.forge.roaster.model;
    +
    +import org.jboss.forge.roaster.Origin;
    +import org.jboss.forge.roaster.model.source.BlockHolder;
    +
    +public interface Block<O extends JavaType,

Missing javadoc


Reply to this email directly or view it on GitHub
https://github.com/forge/roaster/pull/27/files#r35489323.

P extends BlockHolder<O>>
extends Origin<P>,
BlockHolder<O> {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright 2014 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Eclipse Public License version 1.0, available at
* http://www.eclipse.org/legal/epl-v10.html
*/

package org.jboss.forge.roaster.model;

public interface ExpressionHolder<O extends JavaType<O>> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Javadoc is missing


}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package org.jboss.forge.roaster.model;

import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaClassSource;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused import


/**
* Represents a Java {@code class} type. See {@link Roaster} for various options in generating {@link JavaClass}
Expand All @@ -32,5 +33,4 @@ public interface JavaClass<O extends JavaClass<O>> extends
* @return <code>true</code> if this {@link JavaClass} represents a local class.
*/
public boolean isLocalClass();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
* Copyright 2014 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Eclipse Public License version 1.0, available at
* http://www.eclipse.org/legal/epl-v10.html
*/

package org.jboss.forge.roaster.model.expressions;


import org.jboss.forge.roaster.model.ExpressionHolder;
import org.jboss.forge.roaster.model.source.JavaSource;

/**
* Abstract factory interface that supports the construction of accessor expressions, in source format
* The expression returns an object with accessible fields, accessors and methods
*
* @author <a href="dsotty@gmail.com">Davide Sottara</a>
*/
public interface AccessBuilder<O extends JavaSource<O>,
P extends ExpressionHolder<O>,
E extends NonPrimitiveExpression<O,P,E>>
{

/**
* Returns a field access expression
* Can be invoked on a parent expression
* @param field The name of the field
* @return a field accessor
*/
public Field<O,E> field(String field);

/**
* Returns a getter expression
* Can be invoked on a parent expression
* @param field The name of the field
* @param klass The name of the type of the field
* @return a getter method invocation expression
*/
public Getter<O,E> getter(String field, String klass);

/**
* Returns a getter expression
* Can be invoked on a parent expression
* @param field The name of the field
* @param klass The type of the field
* @return a getter method invocation expression
*/
public Getter<O,E> getter(String field, Class klass);

/**
* Returns a setter expression
* Can be invoked on a parent expression
* @param field The name of the field
* @param klass The name of the type of the field
* @param value The expression returning the value to be set
* @return a setter method invocation expression
*/
public Setter<O,E> setter(String field, String klass, ExpressionSource<?,?,?> value);

/**
* Returns a setter expression
* Can be invoked on a parent expression
* @param field The name of the field
* @param klass The type of the field
* @param value The expression returning the value to be set
* @return a setter method invocation expression
*/
public Setter<O,E> setter(String field, Class klass, ExpressionSource<?,?,?> value);

/**
* Returns a method invocation expression
* Can be invoked on a parent expression
* @param method The name of the method
* @return a method invocation expression
*/
public MethodCallExpression<O,E> invoke(String method);

/**
* Returns an array indexing expression
* Can be invoked on a parent expression
* @param index The expression returning the index used for accessing the array
* @return an array indexing expression
*/
public ArrayIndexer<O,E> itemAt(ExpressionSource<?,?,?> index);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright 2014 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Eclipse Public License version 1.0, available at
* http://www.eclipse.org/legal/epl-v10.html
*/

package org.jboss.forge.roaster.model.expressions;

import org.jboss.forge.roaster.model.ExpressionHolder;
import org.jboss.forge.roaster.model.source.JavaSource;

/**
* Abstract interface that represents accessors (getters, fields, etc..) in source format
*
* @author <a href="dsotty@gmail.com">Davide Sottara</a>
*/
public interface Accessor<O extends JavaSource<O>,
P extends ExpressionHolder<O>,
E extends NonPrimitiveExpression<O,P,E>>
extends Argument<O,P,E>,
AccessBuilder<O,P,E>
{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright 2014 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Eclipse Public License version 1.0, available at
* http://www.eclipse.org/legal/epl-v10.html
*/

package org.jboss.forge.roaster.model.expressions;


import org.jboss.forge.roaster.model.ExpressionHolder;
import org.jboss.forge.roaster.model.source.JavaSource;

/**
* Abstract marker interface that represents operation or method arguments in source format
*
* @author <a href="dsotty@gmail.com">Davide Sottara</a>
*/
public interface Argument<O extends JavaSource<O>,
P extends ExpressionHolder<O>,
E extends ExpressionSource<O,P,E>>
extends ExpressionSource<O,P,E>
{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright 2014 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Eclipse Public License version 1.0, available at
* http://www.eclipse.org/legal/epl-v10.html
*/

package org.jboss.forge.roaster.model.expressions;

import org.jboss.forge.roaster.model.ExpressionHolder;
import org.jboss.forge.roaster.model.source.JavaSource;

import java.util.List;

/**
* Abstract marker interface that represents expressions requiring arguments
*
* @author <a href="dsotty@gmail.com">Davide Sottara</a>
*/
public interface ArgumentHolder<O extends JavaSource<O>,
P extends ExpressionHolder<O>,
E extends NonPrimitiveExpression<O,P,?>>
extends ExpressionHolder<O>
{

/**
* Adds an argument to the expression
* @param arg The argument to be added
* @return The expression itself
*/
public E addArgument(Argument<?,?,?> arg);

/**
* Returns the current list of arguments
* @return An immutable list containing the arguments
*/
public List<Argument<O,E,?>> getArguments();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright 2014 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Eclipse Public License version 1.0, available at
* http://www.eclipse.org/legal/epl-v10.html
*/

package org.jboss.forge.roaster.model.expressions;

import org.jboss.forge.roaster.model.ExpressionHolder;
import org.jboss.forge.roaster.model.source.JavaSource;

import java.util.List;

/**
* Represent an array constructor expression in source format
*
* @author <a href="dsotty@gmail.com">Davide Sottara</a>
*/
public interface ArrayConstructorExpression<O extends JavaSource<O>,
P extends ExpressionHolder<O>>
extends Argument<O,P,ArrayConstructorExpression<O,P>>,
NonPrimitiveExpression<O,P,ArrayConstructorExpression<O,P>>
{

/**
* Adds a dimension to the array, allocating <code>dim</code> slots
* @param dim the number of elements in the new array dimension
* @return The <code>ArrayConstructorExpression/code> itself
*/
public ArrayConstructorExpression<O,P> addDimension(ExpressionSource<?,?,?> dim);

/**
* Initializes the array using an <code>ArrayInit</code> expressoin
* @param array the initial value for the array variable
* @return The <code>ArrayConstructorExpression/code> itself
*/
public ArrayConstructorExpression<O,P> init(ArrayInit<?,?> array);

/**
* Returns the array initialization expression, or null if none has been set
* @return An <code>ArrayInit</code> expression
*/
public ArrayInit<O,ArrayConstructorExpression<O,P>> getInit();

/**
* Returns the expressions defining the number of slots for each array dimension
* @return An immutable list containing the expressions initializing each dimension
*/
public List<ExpressionSource<O,ArrayConstructorExpression<O,P>,?>> getDimensions();

/**
* Returns the number of dimensions of the array being constructed
* @return the number of dimensions for this array
*/
public int getDimension();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright 2014 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Eclipse Public License version 1.0, available at
* http://www.eclipse.org/legal/epl-v10.html
*/

package org.jboss.forge.roaster.model.expressions;

import org.jboss.forge.roaster.model.ExpressionHolder;
import org.jboss.forge.roaster.model.source.JavaSource;

/**
* Represent an array indexing expression in source format
*
* @author <a href="dsotty@gmail.com">Davide Sottara</a>
*/
public interface ArrayIndexer<O extends JavaSource<O>, P extends ExpressionHolder<O>>
extends OrdinalArgument<O,P,ArrayIndexer<O,P>>,
NonPrimitiveExpression<O,P,ArrayIndexer<O,P>>,
InvocationTargetHolder<O,P,ArrayIndexer<O,P>>
{

/**
* Returns the expression returning the index to be accessed
* @return The expression returning the index used by this <code>ArrayIndexer</code>
*/
public ExpressionSource<O,ArrayIndexer<O,P>,?> getIndex();

/**
* Sets the expression returning the index to be used for accessing the array
* @param index An expression returning an integer, used to access the array
* @return The <code>ArrayIndexer</code> itself
*/
public ArrayIndexer<O,P> setIndex(ExpressionSource<?,?,?> index);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright 2014 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Eclipse Public License version 1.0, available at
* http://www.eclipse.org/legal/epl-v10.html
*/

package org.jboss.forge.roaster.model.expressions;


import org.jboss.forge.roaster.model.ExpressionHolder;
import org.jboss.forge.roaster.model.source.JavaSource;

import java.util.List;

/**
* Represent an array constructor expression in source format
*
* @author <a href="dsotty@gmail.com">Davide Sottara</a>
*/
public interface ArrayInit<O extends JavaSource<O>, P extends ExpressionHolder<O>>
extends ExpressionSource<O,P,ArrayInit<O,P>>,
NonPrimitiveExpression<O,P,ArrayInit<O,P>>
{

/**
* Adds a sub-array literal to this array constructing expression
* @param subRow The sub-array
* @return The <code>ArrayInit</code> itself
*/
public ArrayInit<O,P> addElement(ArrayInit<?,?> subRow);

/**
* Adds an element to this array constructing expression
* @param subElement The expression returning the element to be addeed to the array
* @return The <code>ArrayInit</code> itself
*/
public ArrayInit<O,P> addElement(ExpressionSource<?,?,?> subElement);

/**
* Returns the current elements used to initialize the array
* @return An immutable list containing the element expressions
*/
public List<ExpressionSource<O,ArrayInit<O,P>,?>> getElements();

/**
* Counts and returns the number of elements in this array
* @return
*/
public int size();

/**
* Returns the number of dimensions in the array, as inferred by the init expressions
* Example : { {1}, {2}, {3} } size() is 3, but getDimension() is 2
* @return the dimension
*/
public int getDimension();

}
Loading