Created
October 21, 2015 15:07
-
-
Save cviebig/1e46aaef485ce97dc322 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.carma.swagger.doclet.sampleb; | |
import org.codehaus.jackson.map.annotate.JsonView; | |
@SuppressWarnings("javadoc") | |
public class Comment { | |
public interface CommentView { | |
// noop | |
} | |
public interface UserView extends User.UserView { | |
// noop | |
} | |
public interface CommentThreadView extends CommentThread.CommentThreadView { | |
// noop | |
} | |
@JsonView(Comment.CommentView.class) | |
protected String text; | |
@JsonView(Comment.UserView.class) | |
protected User user; | |
@JsonView(Comment.CommentThreadView.class) | |
protected CommentThread commentThread; | |
/** | |
* This gets the text | |
* @return the text | |
*/ | |
public String getText() { | |
return this.text; | |
} | |
/** | |
* This sets the text | |
* @param text the text to set | |
*/ | |
public void setText(String text) { | |
this.text = text; | |
} | |
/** | |
* This gets the user | |
* @return the user | |
*/ | |
public User getUser() { | |
return this.user; | |
} | |
/** | |
* This sets the user | |
* @param user the user to set | |
*/ | |
public void setUser(User user) { | |
this.user = user; | |
} | |
/** | |
* This gets the commentThread | |
* @return the commentThread | |
*/ | |
public CommentThread getCommentThread() { | |
return this.commentThread; | |
} | |
/** | |
* This sets the commentThread | |
* @param commentThread the commentThread to set | |
*/ | |
public void setCommentThread(CommentThread commentThread) { | |
this.commentThread = commentThread; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.carma.swagger.doclet.sampleb; | |
import java.util.List; | |
import org.codehaus.jackson.map.annotate.JsonView; | |
@SuppressWarnings("javadoc") | |
public class CommentThread { | |
public interface CommentThreadView { | |
// noop | |
} | |
public interface CommentView extends Comment.UserView { | |
// noop | |
} | |
@JsonView(CommentThread.CommentThreadView.class) | |
protected String name; | |
@JsonView(CommentThread.CommentView.class) | |
protected List<Comment> comments; | |
/** | |
* This gets the name | |
* @return the name | |
*/ | |
public String getName() { | |
return this.name; | |
} | |
/** | |
* This sets the name | |
* @param name the name to set | |
*/ | |
public void setName(String name) { | |
this.name = name; | |
} | |
/** | |
* This gets the comments | |
* @return the comments | |
*/ | |
public List<Comment> getComments() { | |
return this.comments; | |
} | |
/** | |
* This sets the comments | |
* @param comments the comments to set | |
*/ | |
public void setComments(List<Comment> comments) { | |
this.comments = comments; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.carma.swagger.doclet.sampleb; | |
import java.util.ArrayList; | |
import javax.ws.rs.GET; | |
import javax.ws.rs.POST; | |
import javax.ws.rs.Path; | |
import javax.ws.rs.Produces; | |
import javax.ws.rs.core.MediaType; | |
import org.codehaus.jackson.map.annotate.JsonView; | |
import org.springframework.stereotype.Service; | |
@Path("jsonviewb") | |
@Produces({ MediaType.APPLICATION_JSON }) | |
@Service | |
@SuppressWarnings("javadoc") | |
public class IssueResource { | |
@GET | |
@JsonView(User.UserView.class) | |
public User getUser() { | |
User u = new User(); | |
u.name = "Name"; | |
u.comments = new ArrayList<Comment>(1); | |
CommentThread t = new CommentThread(); | |
t.name = "Name"; | |
t.comments = new ArrayList<Comment>(1); | |
Comment c = new Comment(); | |
c.text = "Text"; | |
c.user = u; | |
c.commentThread = t; | |
u.comments.add(c); | |
t.comments.add(c); | |
return u; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.carma.swagger.doclet.sampleb; | |
import java.util.Collection; | |
import org.codehaus.jackson.map.annotate.JsonView; | |
@SuppressWarnings("javadoc") | |
public class User { | |
public interface UserView extends NameView, CommentView { | |
// noop | |
} | |
public interface NameView { | |
// noop | |
} | |
public interface CommentView extends Comment.CommentView { | |
// noop | |
} | |
@JsonView(User.NameView.class) | |
protected String name; | |
@JsonView(User.CommentView.class) | |
protected Collection<Comment> comments; | |
/** | |
* This gets the name | |
* @return the name | |
*/ | |
public String getName() { | |
return this.name; | |
} | |
/** | |
* This sets the name | |
* @param name the name to set | |
*/ | |
public void setName(String name) { | |
this.name = name; | |
} | |
/** | |
* This gets the comments | |
* @return the comments | |
*/ | |
public Collection<Comment> getComments() { | |
return this.comments; | |
} | |
/** | |
* This sets the comments | |
* @param comments the comments to set | |
*/ | |
public void setComments(Collection<Comment> comments) { | |
this.comments = comments; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment