Skip to content
Snippets Groups Projects
Commit 3d37fd44 authored by René Schöne's avatar René Schöne
Browse files

New version of relast, removing NTA-token.

parent 96c4a887
No related branches found
No related tags found
1 merge request!1All4one relast
......@@ -2,3 +2,5 @@
/src/gen-res/
/build/
events.txt
/src/main/jastadd/SocialNetworkGen.ast
/src/main/jastadd/SocialNetworkGen.jadd
No preview for this file type
......@@ -4,8 +4,7 @@ SocialNetwork : ModelElement ::= User* Post* ;
User:ModelElement ::= <Name:String> ;
abstract Submission : ModelElement ::= <Timestamp:Long> <Content:String> Comment* ;
// Comment : Submission ::= /<Post:Post>/ ;
Comment : Submission ::= <Post:Post> ;
Comment : Submission ::= ;
Post : Submission ::= ;
rel User.friends* -> User ;
......
abstract ModelElement ::= <Id:Long>;
SocialNetwork : ModelElement ::= User* Post*;
User : ModelElement ::= <Name:String> <_impl_friends:RefList<User>> <_impl_submissions:RefList<Submission>> <_impl_likes:RefList<Comment>>;
abstract Submission : ModelElement ::= <Timestamp:Long> <Content:String> Comment*;
Comment : Submission ::= /<Post:Post>/ <_impl_likedBy:RefList<User>>;
Post : Submission;
import java.util.ArrayList;
import java.util.Collections;
aspect RelAstAPI {
public User.User(Long Id, String Name) {
setId(Id);
setName(Name);
}
public Comment.Comment(Long Id, Long Timestamp, String Content, List<Comment> Comment) {
setId(Id);
setTimestamp(Timestamp);
setContent(Content);
setCommentList(Comment);
}
// rel User.friends* -> User
public java.util.List<User> User.friends() {
RefList<User> l = get_impl_friends();
return l != null ? Collections.unmodifiableList(l) : Collections.emptyList();
}
public void User.addToFriends(User o) {
assertNotNull(o);
RefList<User> list = get_impl_friends();
if (list == null) {
list = new RefList<>();
}
list.add(o);
set_impl_friends(list);
}
public void User.removeFromFriends(User o) {
assertNotNull(o);
RefList<User> list = get_impl_friends();
if (list != null && list.remove(o)) {
set_impl_friends(list);
}
}
// rel User.submissions* -> Submission
public java.util.List<Submission> User.submissions() {
RefList<Submission> l = get_impl_submissions();
return l != null ? Collections.unmodifiableList(l) : Collections.emptyList();
}
public void User.addToSubmissions(Submission o) {
assertNotNull(o);
RefList<Submission> list = get_impl_submissions();
if (list == null) {
list = new RefList<>();
}
list.add(o);
set_impl_submissions(list);
}
public void User.removeFromSubmissions(Submission o) {
assertNotNull(o);
RefList<Submission> list = get_impl_submissions();
if (list != null && list.remove(o)) {
set_impl_submissions(list);
}
}
// rel User.likes* <-> Comment.likedBy*
public java.util.List<Comment> User.likes() {
RefList<Comment> l = get_impl_likes();
return l != null ? Collections.unmodifiableList(l) : Collections.emptyList();
}
public void User.addToLikes(Comment o) {
assertNotNull(o);
RefList<Comment> list = get_impl_likes();
if (list == null) {
list = new RefList<>();
}
RefList<User> list2 = o.get_impl_likedBy();
if (list2 == null) {
list2 = new RefList<>();
}
list.add(o);
list2.add(this);
set_impl_likes(list);
o.set_impl_likedBy(list2);
}
public void User.removeFromLikes(Comment o) {
assertNotNull(o);
RefList<Comment> list = get_impl_likes();
if (list != null && list.remove(o)) {
RefList<User> list2 = o.get_impl_likedBy();
if (list2 != null) list2.remove(this);
set_impl_likes(list);
o.set_impl_likedBy(list2);
}
}
public java.util.List<User> Comment.likedBy() {
RefList<User> l = get_impl_likedBy();
return l != null ? Collections.unmodifiableList(l) : Collections.emptyList();
}
public void Comment.addToLikedBy(User o) {
assertNotNull(o);
RefList<User> list = get_impl_likedBy();
if (list == null) {
list = new RefList<>();
}
RefList<Comment> list2 = o.get_impl_likes();
if (list2 == null) {
list2 = new RefList<>();
}
list.add(o);
list2.add(this);
set_impl_likedBy(list);
o.set_impl_likes(list2);
}
public void Comment.removeFromLikedBy(User o) {
assertNotNull(o);
RefList<User> list = get_impl_likedBy();
if (list != null && list.remove(o)) {
RefList<Comment> list2 = o.get_impl_likes();
if (list2 != null) list2.remove(this);
set_impl_likedBy(list);
o.set_impl_likes(list2);
}
}
public boolean ASTNode.violateLowerBounds() {
return !getLowerBoundsViolations().isEmpty();
}
public java.util.List<Pair<ASTNode, String>> ASTNode.getLowerBoundsViolations() {
ArrayList<Pair<ASTNode, String>> list = new ArrayList<>();
computeLowerBoundsViolations(list);
return list;
}
public void ASTNode.computeLowerBoundsViolations(java.util.List<Pair<ASTNode, String>> list) {
for (int i = 0; i < getNumChildNoTransform(); i++) {
getChildNoTransform(i).computeLowerBoundsViolations(list);
}
}
public class Pair<T1, T2> {
public final T1 _1;
public final T2 _2;
public Pair(T1 _1, T2 _2) {
ASTNode.assertNotNull(_1);
ASTNode.assertNotNull(_2);
this._1 = _1;
this._2 = _2;
}
public boolean equals(Object other) {
if (other instanceof Pair) {
Pair<?,?> p = (Pair<?,?>) other;
return _1.equals(p._1) && _2.equals(p._2);
} else {
return false;
}
}
public int hashCode() {
return 31*_1.hashCode() + _2.hashCode();
}
}
public static void ASTNode.assertNotNull(Object obj) {
if (obj == null) {
throw new NullPointerException();
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment