Commit 57e81d82 authored by Lionel Seinturier's avatar Lionel Seinturier
Browse files

Add another dimension of genericity to the elements of the metamodel...

Add another dimension of genericity to the elements of the metamodel corresponding to interfaces to support contingency.
parent 43a704a1
......@@ -51,8 +51,11 @@ import javax.tools.JavaFileObject;
import org.objectweb.fractal.fraclet.annotations.Requires;
import org.objectweb.fractal.fraclet.types.Cardinality;
import org.objectweb.fractal.fraclet.types.Constants;
import org.objectweb.fractal.fraclet.types.Contingency;
import org.objectweb.fractal.juliac.adlet.api.ComponentCollectiongInterfaceImpl;
import org.objectweb.fractal.juliac.adlet.api.ComponentInterfaceImpl;
import org.objectweb.fractal.juliac.adlet.api.Mandatory;
import org.objectweb.fractal.juliac.adlet.api.Optional;
import org.objectweb.fractal.juliac.adlet.api.Provided;
import org.objectweb.fractal.juliac.adlet.api.ProvidedCollection;
import org.objectweb.fractal.juliac.adlet.api.Required;
......@@ -232,6 +235,9 @@ public class StaticMetamodelProcessor extends AbstractProcessor {
Object cardinality =
AnnotationMirrorHelper.getParameterValue(
am,elements,"cardinality");
Object contingency =
AnnotationMirrorHelper.getParameterValue(
am,elements,"contingency");
int modifiers = Modifier.PUBLIC + Modifier.STATIC;
StringBuffer type = new StringBuffer();
......@@ -256,6 +262,13 @@ public class StaticMetamodelProcessor extends AbstractProcessor {
type.append(className);
type.append(',');
type.append(BOTTOM);
type.append(',');
if( contingency.toString().equals(Contingency.OPTIONAL.toString()) ) {
type.append(Optional.class.getName());
}
else {
type.append(Mandatory.class.getName());
}
type.append('>');
expression.append("<>(");
......@@ -287,6 +300,9 @@ public class StaticMetamodelProcessor extends AbstractProcessor {
Object cardinality =
AnnotatedConstructHelper.getAnnotationParamValue(
field,Requires.class,"cardinality",processingEnv);
Object contingency =
AnnotatedConstructHelper.getAnnotationParamValue(
field,Requires.class,"contingency",processingEnv);
Object signature =
AnnotatedConstructHelper.getAnnotationParamValue(
field,Requires.class,"signature",processingEnv);
......@@ -322,6 +338,13 @@ public class StaticMetamodelProcessor extends AbstractProcessor {
type.append(className);
type.append(',');
type.append(BOTTOM);
type.append(',');
if( contingency.toString().equals(Contingency.OPTIONAL.toString()) ) {
type.append(Optional.class.getName());
}
else {
type.append(Mandatory.class.getName());
}
type.append('>');
expression.append("<>(");
......
......@@ -81,8 +81,8 @@ public class Binder {
* @param r the required interface from the source component
* @param p the provided interface from the target component
*/
public <RTYPE, PTYPE extends RTYPE, PARENT>
void normal( Required<RTYPE,PARENT,?,?> r, Provided<PTYPE,PARENT,?,?> p ) {
public <RTYPE, PTYPE extends RTYPE, PARENT, RCTGY, PCTGY extends RCTGY>
void normal( Required<RTYPE,PARENT,?,?,RCTGY> r, Provided<PTYPE,PARENT,?,?,PCTGY> p ) {
BindingDesc bd =
new BindingDesc(
......@@ -100,9 +100,9 @@ public class Binder {
* @param r the provided interface from the parent component
* @param p the provided interface from the subcomponent
*/
public <RTYPE, PTYPE extends RTYPE, RCURRENT, PBOTTOM extends RCURRENT>
public <RTYPE, PTYPE extends RTYPE, RCURRENT, PBOTTOM extends RCURRENT, RCTGY, PCTGY extends RCTGY>
void export(
Provided<RTYPE,?,RCURRENT,?> r, Provided<PTYPE,?,?,PBOTTOM> p ) {
Provided<RTYPE,?,RCURRENT,?,RCTGY> r, Provided<PTYPE,?,?,PBOTTOM,PCTGY> p ) {
BindingDesc bd =
new BindingDesc(
......@@ -121,9 +121,9 @@ public class Binder {
* @param r the required interface from the subcomponent
* @param p the required interface from the parent component
*/
public <RTYPE, PTYPE extends RTYPE, RBOTTOM extends PCURRENT, PCURRENT>
public <RTYPE, PTYPE extends RTYPE, RBOTTOM extends PCURRENT, PCURRENT, RCTGY, PCTGY extends RCTGY>
void impor(
Required<RTYPE,?,?,RBOTTOM> r, Required<PTYPE,?,PCURRENT,?> p ) {
Required<RTYPE,?,?,RBOTTOM,RCTGY> r, Required<PTYPE,?,PCURRENT,?,PCTGY> p ) {
BindingDesc bd =
new BindingDesc(
......
......@@ -30,11 +30,11 @@ package org.objectweb.fractal.juliac.adlet.api;
* @since 2.7
* @see Required
*/
public class ComponentCollectiongInterfaceImpl<TYPE,PARENT,CURRENT,BOTTOM>
extends ComponentInterfaceImpl<TYPE,PARENT,CURRENT,BOTTOM>
public class ComponentCollectiongInterfaceImpl<TYPE,PARENT,CURRENT,BOTTOM,CTGY>
extends ComponentInterfaceImpl<TYPE,PARENT,CURRENT,BOTTOM,CTGY>
implements
RequiredCollection<TYPE,PARENT,CURRENT,BOTTOM>,
ProvidedCollection<TYPE,PARENT,CURRENT,BOTTOM> {
RequiredCollection<TYPE,PARENT,CURRENT,BOTTOM,CTGY>,
ProvidedCollection<TYPE,PARENT,CURRENT,BOTTOM,CTGY> {
private String suffix;
......@@ -42,7 +42,7 @@ implements
super(component,name);
}
public ComponentCollectiongInterfaceImpl<TYPE,PARENT,CURRENT,BOTTOM>
public ComponentCollectiongInterfaceImpl<TYPE,PARENT,CURRENT,BOTTOM,CTGY>
setSuffix( String suffix ) {
this.suffix = suffix;
return this;
......
......@@ -30,9 +30,10 @@ package org.objectweb.fractal.juliac.adlet.api;
* @since 2.7
* @see Required
*/
public class ComponentInterfaceImpl<TYPE,PARENT,CURRENT,BOTTOM>
public class ComponentInterfaceImpl<TYPE,PARENT,CURRENT,BOTTOM,CTGY>
implements
Required<TYPE,PARENT,CURRENT,BOTTOM>, Provided<TYPE,PARENT,CURRENT,BOTTOM> {
Required<TYPE,PARENT,CURRENT,BOTTOM,CTGY>,
Provided<TYPE,PARENT,CURRENT,BOTTOM,CTGY> {
private Class<?> component;
protected String name;
......
/***
* Juliac
* Copyright (C) 2017 Inria, Univ. Lille 1
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Contact: fractal@ow2.org
*
* Author: Lionel Seinturier
*/
package org.objectweb.fractal.juliac.adlet.api;
/**
* A marker type for mandatory component interfaces.
*
* @author Lionel Seinturier <Lionel.Seinturier@univ-lille1.fr>
* @since 2.7
*/
public interface Mandatory extends Optional {}
/***
* Juliac
* Copyright (C) 2017 Inria, Univ. Lille 1
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Contact: fractal@ow2.org
*
* Author: Lionel Seinturier
*/
package org.objectweb.fractal.juliac.adlet.api;
/**
* A marker type for optional component interfaces.
*
* @author Lionel Seinturier <Lionel.Seinturier@univ-lille1.fr>
* @since 2.7
*/
public interface Optional {}
......@@ -30,6 +30,6 @@ package org.objectweb.fractal.juliac.adlet.api;
* @since 2.7
* @see Required
*/
public interface Provided<TYPE,PARENT,CURRENT,BOTTOM>
public interface Provided<TYPE,PARENT,CURRENT,BOTTOM,CTGY>
extends ComponentInterfaceItf {
}
......@@ -30,9 +30,9 @@ package org.objectweb.fractal.juliac.adlet.api;
* @since 2.7
* @see Required
*/
public interface ProvidedCollection<TYPE,PARENT,CURRENT,BOTTOM>
extends Provided<TYPE,PARENT,CURRENT,BOTTOM> {
public interface ProvidedCollection<TYPE,PARENT,CURRENT,BOTTOM,CTGY>
extends Provided<TYPE,PARENT,CURRENT,BOTTOM,CTGY> {
public ProvidedCollection<TYPE,PARENT,CURRENT,BOTTOM>
public ProvidedCollection<TYPE,PARENT,CURRENT,BOTTOM,CTGY>
setSuffix( String suffix );
}
......@@ -36,18 +36,20 @@ package org.objectweb.fractal.juliac.adlet.api;
* </p>
*
* @param <TYPE>
* the type of this component interface
* the type of this component interface
* @param <PARENT>
* the type of the parent component of the component defining this
* component interface
* the type of the parent component of the component defining this
* component interface
* @param <CURRENT>
* the type of the component defining this component interface
* the type of the component defining this component interface
* @param <BOTTOM>
* a generated subtype of PARENT
* a generated subtype of PARENT
* @param <CTGY>
* the contingency of this component interface
*
* @author Lionel Seinturier <Lionel.Seinturier@univ-lille1.fr>
* @since 2.7
*/
public interface Required<TYPE,PARENT,CURRENT,BOTTOM>
public interface Required<TYPE,PARENT,CURRENT,BOTTOM,CTGY>
extends ComponentInterfaceItf {
}
......@@ -30,9 +30,9 @@ package org.objectweb.fractal.juliac.adlet.api;
* @since 2.7
* @see Required
*/
public interface RequiredCollection<TYPE,PARENT,CURRENT,BOTTOM>
extends Required<TYPE,PARENT,CURRENT,BOTTOM> {
public interface RequiredCollection<TYPE,PARENT,CURRENT,BOTTOM,CTGY>
extends Required<TYPE,PARENT,CURRENT,BOTTOM,CTGY> {
public RequiredCollection<TYPE,PARENT,CURRENT,BOTTOM>
public RequiredCollection<TYPE,PARENT,CURRENT,BOTTOM,CTGY>
setSuffix( String suffix );
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment