Skip to content

Commit

Permalink
Change @Predicate and @term in @id and @param
Browse files Browse the repository at this point in the history
  • Loading branch information
dave90 committed Mar 23, 2017
1 parent cde37a0 commit caee0e0
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface Predicate {
public @interface Id {
String value();
}
16 changes: 8 additions & 8 deletions app/src/main/java/it/unical/mat/embasp/languages/Mapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,20 @@ public String getString(final Object obj) throws IllegalAccessException, Illegal
final HashMap<Integer, Object> parametersMap = new HashMap<>();
for (final Field field : obj.getClass().getDeclaredFields()) {
if (field.isSynthetic()) continue;
if (field.isAnnotationPresent(Term.class)) {
if (field.isAnnotationPresent(Param.class)) {
final Object value = obj.getClass().getMethod("get" + Character.toUpperCase(field.getName().charAt(0)) + field.getName().substring(1))
.invoke(obj);
parametersMap.put(field.getAnnotation(Term.class).value(), value);
parametersMap.put(field.getAnnotation(Param.class).value(), value);
}
}
return getActualString(predicate, parametersMap);
}

private void populateObject(final Class<?> cl, final String[] parameters, final Object obj) throws IllegalAccessException, InvocationTargetException {
for (final Field field : cl.getDeclaredFields())
if (field.isAnnotationPresent(Term.class)) {
if (field.isAnnotationPresent(Param.class)) {

final int term = field.getAnnotation(Term.class).value();
final int term = field.getAnnotation(Param.class).value();
final String nameMethod = "set" + Character.toUpperCase(field.getName().charAt(0)) + field.getName().substring(1);
final Method method = classSetterMethod.get(cl).get(nameMethod);

Expand All @@ -127,12 +127,12 @@ private void populateObject(final Class<?> cl, final String[] parameters, final
*/
public String registerClass(final Class<?> cl) throws ObjectNotValidException, IllegalAnnotationException {

final Annotation annotation = cl.getAnnotation(Predicate.class);
final Annotation annotation = cl.getAnnotation(Id.class);

if (annotation == null)
throw new IllegalAnnotationException();

final String predicate = ((Predicate) annotation).value();
final String predicate = ((Id) annotation).value();

if (predicate.contains(" "))
throw new ObjectNotValidException();
Expand All @@ -149,12 +149,12 @@ public String registerClass(final Class<?> cl) throws ObjectNotValidException, I

public void unregisterClass(final Class<?> cl) throws IllegalAnnotationException {

final Annotation annotation = cl.getAnnotation(Predicate.class);
final Annotation annotation = cl.getAnnotation(Id.class);

if (annotation == null)
throw new IllegalAnnotationException();

final String predicate = ((Predicate) annotation).value();
final String predicate = ((Id) annotation).value();

predicateClass.remove(predicate);
classSetterMethod.remove(cl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Term {
public @interface Param {
int value();
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package it.unical.mat.embasp.language.asp;

import it.unical.mat.embasp.languages.Predicate;
import it.unical.mat.embasp.languages.Id;

@Predicate("a")
@Id("a")
public class Arity0 {

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package it.unical.mat.embasp.specializations.dlv;

import it.unical.mat.embasp.languages.Predicate;
import it.unical.mat.embasp.languages.Term;
import it.unical.mat.embasp.languages.Id;
import it.unical.mat.embasp.languages.Param;

@Predicate("cell")
@Id("cell")
public class Cell {
@Term(0)
@Param(0)
private int row;
@Term(1)
@Param(1)
private int column;
@Term(2)
@Param(2)
private int value;

public Cell() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
*/
package it.unical.mat.embasp.specializations.solver_planning_domains;

import it.unical.mat.embasp.languages.Predicate;
import it.unical.mat.embasp.languages.Term;
import it.unical.mat.embasp.languages.Id;
import it.unical.mat.embasp.languages.Param;

@Predicate("pick-up")
@Id("pick-up")
public class PickUp {

@Term(0)
@Param(0)
private String block;

/**
Expand Down

0 comments on commit caee0e0

Please sign in to comment.