Skip to content

Instantly share code, notes, and snippets.

@catalinghita8
Last active August 1, 2017 15:56
Show Gist options
  • Save catalinghita8/d7d659d157e78e3dd099584a7060fd5a to your computer and use it in GitHub Desktop.
Save catalinghita8/d7d659d157e78e3dd099584a7060fd5a to your computer and use it in GitHub Desktop.
@IgnoreExtraProperties
public class BookObject extends ArrayList<BookObject> {
public String title;
public String subtitle;
public String authors;
public String imageURL;
private String pushId;
public BookObject(){}
public BookObject(String Title , String Subtitle , String[] Authors , String ImageURL)
{
this.title = Title;
this.subtitle = Subtitle;
this.authors = ConvertToString(Authors);
this.imageURL = ImageURL;
}
@Exclude
public String ConvertToString(String[] arr)
{
StringBuilder builder = new StringBuilder();
for(int i = 0; i < arr.length; i++)
{
if(i == arr.length - 1) {
builder.append(arr[i]);
builder.append(".");
}
else
{
builder.append(arr[i]);
builder.append(",");
}
}
String str = builder.toString();
return str;
}
public String getTitle()
{
return title;
}
public String getSubtitle()
{
return subtitle;
}
public String getAuthors()
{
return authors;
}
public String getImageURL(){ return imageURL;}
public String getPushId() {return pushId;}
public void setPushId(String pushId) {this.pushId = pushId;}
@Exclude
public Map<String, Object> toMap() {
HashMap<String, Object> result = new HashMap<>();
result.put("title", title);
result.put("subtitle", subtitle);
result.put("authors", authors);
result.put("imageURL", imageURL);
return result;
}
}
@umangmoe
Copy link

`@IgnoreExtraProperties
public class BookObject extends ArrayList {
public String Title;
public String Subtitle;
public String Authors;
public String ImageURL;
@exclude
private String pushId;

public BookObject(){}
public BookObject(String Title , String Subtitle , String[] Authors , String ImageURL)
{
    this.Title = Title;
    this.Subtitle = Subtitle;
    this.Authors = ConvertToString(Authors);
    this.ImageURL = ImageURL;
}

@Exclude
public String ConvertToString(String[] arr)
{
    StringBuilder builder = new StringBuilder();

        for(int i = 0; i < arr.length; i++)
        {
            if(i == arr.length - 1) {
                builder.append(arr[i]);
                builder.append(".");
            }
            else
            {
                builder.append(arr[i]);
                builder.append(",");
            }
        }

    String str = builder.toString();
    return str;

}
public String getTitle()
{
    return Title;
}
public String getSubtitle()
{
    return Subtitle;
}
public String getAuthors()
{
    return Authors;
}
public String getImageURL(){ return ImageURL;}

@exclude
public String getPushId() {
return pushId;
}

@exclude
public void setPushId(String pushId) {
this.pushId = pushId;
}
@exclude
public Map<String, Object> toMap() {
HashMap<String, Object> result = new HashMap<>();
result.put("title", Title);
result.put("subtitle", Subtitle);
result.put("authors", Authors);
result.put("imageURL", ImageURL);

     return result;
     }

}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment