repo_name
stringlengths
7
104
file_path
stringlengths
13
198
context
stringlengths
67
7.15k
import_statement
stringlengths
16
4.43k
code
stringlengths
40
6.98k
prompt
stringlengths
227
8.27k
next_line
stringlengths
8
795
xda/XDA-One
android/src/main/java/com/xda/one/ui/NewsAdapter.java
// Path: android/src/main/java/com/xda/one/util/StringUtils.java // public final class StringUtils { // // private StringUtils() { // throw new UnsupportedOperationException("StringUtil cannot be instantiated"); // } // // public static String removeWhiteSpaces(String str) { // return str.replaceAll("\\s+", " "); // } // // public static String trimCharSequence(final String text, final int size) { // return text.length() > size ? text.substring(0, size) : text; // } // // public static Spanned trimCharSequence(final Spanned spanned, final int size) { // return spanned.length() > size ? new SpannableStringBuilder(spanned, 0, size) : spanned; // } // } // // Path: android/src/main/java/com/xda/one/util/Utils.java // public class Utils { // // public static String handleRetrofitErrorQuietly(final RetrofitError error) { // error.printStackTrace(); // // InputStream inputStream = null; // try { // if (error.isNetworkError()) { // Log.e("XDA-ONE", "Network error happened."); // } else { // final TypedInput body = error.getResponse().getBody(); // if (body == null) { // Log.e("XDA-ONE", "Unable to retrieve body"); // return null; // } // inputStream = body.in(); // // final String result = IOUtils.toString(inputStream); // Log.e("XDA-ONE", result); // return result; // } // } catch (IOException e) { // e.printStackTrace(); // } finally { // IOUtils.closeQuietly(inputStream); // } // return null; // } // // public static <T> int getCollectionSize(final Collection<T> collection) { // return collection == null ? 0 : collection.size(); // } // // public static boolean isCollectionEmpty(final Collection collection) { // return collection == null || collection.isEmpty(); // } // // public static CharSequence getRelativeDate(final Context context, final long dateline) { // return DateUtils.getRelativeDateTimeString(context, dateline, // DateUtils.SECOND_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, // DateUtils.FORMAT_NUMERIC_DATE); // } // }
import com.squareup.picasso.Picasso; import com.xda.one.R; import com.xda.one.api.model.response.ResponseNews; import com.xda.one.util.StringUtils; import com.xda.one.util.Utils; import android.content.Context; import android.support.v7.widget.RecyclerView; import android.text.Html; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import java.util.ArrayList; import java.util.Collections; import java.util.List;
if (position == mNews.size()) { return FOOTER_VIEW_TYPE; } return NORMAL_VIEW_TYPE; } @Override public NewsViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) { if (viewType == FOOTER_VIEW_TYPE) { final View view = mLayoutInflater.inflate(R.layout.load_more_progress_bar_only, parent, false); return new FooterViewType(view); } final View view = mLayoutInflater.inflate(R.layout.news_list_item, parent, false); return new NewsViewHolder(view); } @Override public void onBindViewHolder(final NewsViewHolder holder, final int position) { if (getItemViewType(position) == FOOTER_VIEW_TYPE) { return; } final ResponseNews item = getItem(position); holder.itemView.setTag(item.getUrl()); holder.itemView.setOnClickListener(mOnClickListener); holder.titleView.setText(Html.fromHtml(item.getTitle())); final String content = item.getContent();
// Path: android/src/main/java/com/xda/one/util/StringUtils.java // public final class StringUtils { // // private StringUtils() { // throw new UnsupportedOperationException("StringUtil cannot be instantiated"); // } // // public static String removeWhiteSpaces(String str) { // return str.replaceAll("\\s+", " "); // } // // public static String trimCharSequence(final String text, final int size) { // return text.length() > size ? text.substring(0, size) : text; // } // // public static Spanned trimCharSequence(final Spanned spanned, final int size) { // return spanned.length() > size ? new SpannableStringBuilder(spanned, 0, size) : spanned; // } // } // // Path: android/src/main/java/com/xda/one/util/Utils.java // public class Utils { // // public static String handleRetrofitErrorQuietly(final RetrofitError error) { // error.printStackTrace(); // // InputStream inputStream = null; // try { // if (error.isNetworkError()) { // Log.e("XDA-ONE", "Network error happened."); // } else { // final TypedInput body = error.getResponse().getBody(); // if (body == null) { // Log.e("XDA-ONE", "Unable to retrieve body"); // return null; // } // inputStream = body.in(); // // final String result = IOUtils.toString(inputStream); // Log.e("XDA-ONE", result); // return result; // } // } catch (IOException e) { // e.printStackTrace(); // } finally { // IOUtils.closeQuietly(inputStream); // } // return null; // } // // public static <T> int getCollectionSize(final Collection<T> collection) { // return collection == null ? 0 : collection.size(); // } // // public static boolean isCollectionEmpty(final Collection collection) { // return collection == null || collection.isEmpty(); // } // // public static CharSequence getRelativeDate(final Context context, final long dateline) { // return DateUtils.getRelativeDateTimeString(context, dateline, // DateUtils.SECOND_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, // DateUtils.FORMAT_NUMERIC_DATE); // } // } // Path: android/src/main/java/com/xda/one/ui/NewsAdapter.java import com.squareup.picasso.Picasso; import com.xda.one.R; import com.xda.one.api.model.response.ResponseNews; import com.xda.one.util.StringUtils; import com.xda.one.util.Utils; import android.content.Context; import android.support.v7.widget.RecyclerView; import android.text.Html; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import java.util.ArrayList; import java.util.Collections; import java.util.List; if (position == mNews.size()) { return FOOTER_VIEW_TYPE; } return NORMAL_VIEW_TYPE; } @Override public NewsViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) { if (viewType == FOOTER_VIEW_TYPE) { final View view = mLayoutInflater.inflate(R.layout.load_more_progress_bar_only, parent, false); return new FooterViewType(view); } final View view = mLayoutInflater.inflate(R.layout.news_list_item, parent, false); return new NewsViewHolder(view); } @Override public void onBindViewHolder(final NewsViewHolder holder, final int position) { if (getItemViewType(position) == FOOTER_VIEW_TYPE) { return; } final ResponseNews item = getItem(position); holder.itemView.setTag(item.getUrl()); holder.itemView.setOnClickListener(mOnClickListener); holder.titleView.setText(Html.fromHtml(item.getTitle())); final String content = item.getContent();
final String text = StringUtils.trimCharSequence(Html.fromHtml(content).toString(), 200);
xda/XDA-One
android/src/main/java/com/xda/one/ui/NewsAdapter.java
// Path: android/src/main/java/com/xda/one/util/StringUtils.java // public final class StringUtils { // // private StringUtils() { // throw new UnsupportedOperationException("StringUtil cannot be instantiated"); // } // // public static String removeWhiteSpaces(String str) { // return str.replaceAll("\\s+", " "); // } // // public static String trimCharSequence(final String text, final int size) { // return text.length() > size ? text.substring(0, size) : text; // } // // public static Spanned trimCharSequence(final Spanned spanned, final int size) { // return spanned.length() > size ? new SpannableStringBuilder(spanned, 0, size) : spanned; // } // } // // Path: android/src/main/java/com/xda/one/util/Utils.java // public class Utils { // // public static String handleRetrofitErrorQuietly(final RetrofitError error) { // error.printStackTrace(); // // InputStream inputStream = null; // try { // if (error.isNetworkError()) { // Log.e("XDA-ONE", "Network error happened."); // } else { // final TypedInput body = error.getResponse().getBody(); // if (body == null) { // Log.e("XDA-ONE", "Unable to retrieve body"); // return null; // } // inputStream = body.in(); // // final String result = IOUtils.toString(inputStream); // Log.e("XDA-ONE", result); // return result; // } // } catch (IOException e) { // e.printStackTrace(); // } finally { // IOUtils.closeQuietly(inputStream); // } // return null; // } // // public static <T> int getCollectionSize(final Collection<T> collection) { // return collection == null ? 0 : collection.size(); // } // // public static boolean isCollectionEmpty(final Collection collection) { // return collection == null || collection.isEmpty(); // } // // public static CharSequence getRelativeDate(final Context context, final long dateline) { // return DateUtils.getRelativeDateTimeString(context, dateline, // DateUtils.SECOND_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, // DateUtils.FORMAT_NUMERIC_DATE); // } // }
import com.squareup.picasso.Picasso; import com.xda.one.R; import com.xda.one.api.model.response.ResponseNews; import com.xda.one.util.StringUtils; import com.xda.one.util.Utils; import android.content.Context; import android.support.v7.widget.RecyclerView; import android.text.Html; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import java.util.ArrayList; import java.util.Collections; import java.util.List;
final String text = StringUtils.trimCharSequence(Html.fromHtml(content).toString(), 200); holder.contentView.setText(text); Picasso.with(mContext) .load(item.getThumbnail()) .placeholder(R.drawable.ic_account_circle_light) .error(R.drawable.ic_account_circle_light) .into(holder.imageView); } public ResponseNews getItem(int position) { return mNews.get(position); } @Override public int getItemCount() { return mNews.size() + mFooterItemCount ; } public void clear() { if (isEmpty()) { return; } final int count = mNews.size(); mNews.clear(); notifyItemRangeRemoved(0, count + mFooterItemCount--); } public void addAll(final List<ResponseNews> news) {
// Path: android/src/main/java/com/xda/one/util/StringUtils.java // public final class StringUtils { // // private StringUtils() { // throw new UnsupportedOperationException("StringUtil cannot be instantiated"); // } // // public static String removeWhiteSpaces(String str) { // return str.replaceAll("\\s+", " "); // } // // public static String trimCharSequence(final String text, final int size) { // return text.length() > size ? text.substring(0, size) : text; // } // // public static Spanned trimCharSequence(final Spanned spanned, final int size) { // return spanned.length() > size ? new SpannableStringBuilder(spanned, 0, size) : spanned; // } // } // // Path: android/src/main/java/com/xda/one/util/Utils.java // public class Utils { // // public static String handleRetrofitErrorQuietly(final RetrofitError error) { // error.printStackTrace(); // // InputStream inputStream = null; // try { // if (error.isNetworkError()) { // Log.e("XDA-ONE", "Network error happened."); // } else { // final TypedInput body = error.getResponse().getBody(); // if (body == null) { // Log.e("XDA-ONE", "Unable to retrieve body"); // return null; // } // inputStream = body.in(); // // final String result = IOUtils.toString(inputStream); // Log.e("XDA-ONE", result); // return result; // } // } catch (IOException e) { // e.printStackTrace(); // } finally { // IOUtils.closeQuietly(inputStream); // } // return null; // } // // public static <T> int getCollectionSize(final Collection<T> collection) { // return collection == null ? 0 : collection.size(); // } // // public static boolean isCollectionEmpty(final Collection collection) { // return collection == null || collection.isEmpty(); // } // // public static CharSequence getRelativeDate(final Context context, final long dateline) { // return DateUtils.getRelativeDateTimeString(context, dateline, // DateUtils.SECOND_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, // DateUtils.FORMAT_NUMERIC_DATE); // } // } // Path: android/src/main/java/com/xda/one/ui/NewsAdapter.java import com.squareup.picasso.Picasso; import com.xda.one.R; import com.xda.one.api.model.response.ResponseNews; import com.xda.one.util.StringUtils; import com.xda.one.util.Utils; import android.content.Context; import android.support.v7.widget.RecyclerView; import android.text.Html; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import java.util.ArrayList; import java.util.Collections; import java.util.List; final String text = StringUtils.trimCharSequence(Html.fromHtml(content).toString(), 200); holder.contentView.setText(text); Picasso.with(mContext) .load(item.getThumbnail()) .placeholder(R.drawable.ic_account_circle_light) .error(R.drawable.ic_account_circle_light) .into(holder.imageView); } public ResponseNews getItem(int position) { return mNews.get(position); } @Override public int getItemCount() { return mNews.size() + mFooterItemCount ; } public void clear() { if (isEmpty()) { return; } final int count = mNews.size(); mNews.clear(); notifyItemRangeRemoved(0, count + mFooterItemCount--); } public void addAll(final List<ResponseNews> news) {
if (Utils.isCollectionEmpty(news)) {
xda/XDA-One
android/src/main/java/com/xda/one/api/model/response/container/ResponseQuoteContainer.java
// Path: android/src/main/java/com/xda/one/api/model/response/ResponseQuote.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class ResponseQuote implements Quote { // // public static final Creator<ResponseQuote> CREATOR = new Creator<ResponseQuote>() { // @Override // public ResponseQuote createFromParcel(Parcel source) { // return new ResponseQuote(source); // } // // @Override // public ResponseQuote[] newArray(int size) { // return new ResponseQuote[size]; // } // }; // // private final ResponseAvatar mResponseAvatar; // // @JsonProperty("pagetext") // private String mPageText; // // @JsonProperty("dateline") // private int mDateLine; // // @JsonProperty("postid") // private String mPostId; // // @JsonProperty("type") // private String mType; // // @JsonProperty("userid") // private String mUserId; // // @JsonProperty("username") // private String mUserName; // // @JsonProperty("quoteduserid") // private String mQuotedUserId; // // @JsonProperty("quotedusername") // private String mQuotedUserName; // // @JsonProperty("quotedusergroupid") // private int mQuotedUserGroupId; // // @JsonProperty("quotedinfractiongroupid") // private int mQuotedInfractionGroupId; // // @JsonProperty("thread") // private ResponseUnifiedThread mThread; // // public ResponseQuote() { // mResponseAvatar = new ResponseAvatar(); // } // // public ResponseQuote(final Parcel in) { // mResponseAvatar = new ResponseAvatar(in); // // mPageText = in.readString(); // mDateLine = in.readInt(); // mPostId = in.readString(); // mType = in.readString(); // mUserId = in.readString(); // mUserName = in.readString(); // mQuotedUserId = in.readString(); // mQuotedUserName = in.readString(); // mQuotedUserGroupId = in.readInt(); // mQuotedInfractionGroupId = in.readInt(); // mThread = in.readParcelable(ResponseUnifiedThread.class.getClassLoader()); // } // // @Override // public String getPageText() { // return mPageText; // } // // @Override // public int getDateLine() { // return mDateLine; // } // // @Override // public String getPostId() { // return mPostId; // } // // @Override // public String getType() { // return mType; // } // // @Override // public String getUserId() { // return mUserId; // } // // @Override // public String getUserName() { // return mUserName; // } // // @Override // public String getQuotedUserId() { // return mQuotedUserId; // } // // @Override // public String getQuotedUserName() { // return mQuotedUserName; // } // // @Override // public int getQuotedUserGroupId() { // return mQuotedUserGroupId; // } // // @Override // public int getQuotedInfractionGroupId() { // return mQuotedInfractionGroupId; // } // // @Override // public UnifiedThread getThread() { // return mThread; // } // // @Override // public String getAvatarUrl() { // return mResponseAvatar.getAvatarUrl(); // } // // @JsonProperty("avatar_url") // public void setAvatarUrl(final String avatarUrl) { // mResponseAvatar.setAvatarUrl(avatarUrl); // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(final Parcel dest, final int flags) { // mResponseAvatar.writeToParcel(dest, flags); // // dest.writeString(mPageText); // dest.writeInt(mDateLine); // dest.writeString(mPostId); // dest.writeString(mType); // dest.writeString(mUserId); // dest.writeString(mUserName); // dest.writeString(mQuotedUserId); // dest.writeString(mQuotedUserName); // dest.writeInt(mQuotedUserGroupId); // dest.writeInt(mQuotedInfractionGroupId); // dest.writeParcelable(mThread, 0); // } // }
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.xda.one.api.model.interfaces.container.QuoteContainer; import com.xda.one.api.model.response.ResponseQuote; import java.util.List;
package com.xda.one.api.model.response.container; @JsonIgnoreProperties(ignoreUnknown = true) public class ResponseQuoteContainer implements QuoteContainer { @JsonProperty("results")
// Path: android/src/main/java/com/xda/one/api/model/response/ResponseQuote.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class ResponseQuote implements Quote { // // public static final Creator<ResponseQuote> CREATOR = new Creator<ResponseQuote>() { // @Override // public ResponseQuote createFromParcel(Parcel source) { // return new ResponseQuote(source); // } // // @Override // public ResponseQuote[] newArray(int size) { // return new ResponseQuote[size]; // } // }; // // private final ResponseAvatar mResponseAvatar; // // @JsonProperty("pagetext") // private String mPageText; // // @JsonProperty("dateline") // private int mDateLine; // // @JsonProperty("postid") // private String mPostId; // // @JsonProperty("type") // private String mType; // // @JsonProperty("userid") // private String mUserId; // // @JsonProperty("username") // private String mUserName; // // @JsonProperty("quoteduserid") // private String mQuotedUserId; // // @JsonProperty("quotedusername") // private String mQuotedUserName; // // @JsonProperty("quotedusergroupid") // private int mQuotedUserGroupId; // // @JsonProperty("quotedinfractiongroupid") // private int mQuotedInfractionGroupId; // // @JsonProperty("thread") // private ResponseUnifiedThread mThread; // // public ResponseQuote() { // mResponseAvatar = new ResponseAvatar(); // } // // public ResponseQuote(final Parcel in) { // mResponseAvatar = new ResponseAvatar(in); // // mPageText = in.readString(); // mDateLine = in.readInt(); // mPostId = in.readString(); // mType = in.readString(); // mUserId = in.readString(); // mUserName = in.readString(); // mQuotedUserId = in.readString(); // mQuotedUserName = in.readString(); // mQuotedUserGroupId = in.readInt(); // mQuotedInfractionGroupId = in.readInt(); // mThread = in.readParcelable(ResponseUnifiedThread.class.getClassLoader()); // } // // @Override // public String getPageText() { // return mPageText; // } // // @Override // public int getDateLine() { // return mDateLine; // } // // @Override // public String getPostId() { // return mPostId; // } // // @Override // public String getType() { // return mType; // } // // @Override // public String getUserId() { // return mUserId; // } // // @Override // public String getUserName() { // return mUserName; // } // // @Override // public String getQuotedUserId() { // return mQuotedUserId; // } // // @Override // public String getQuotedUserName() { // return mQuotedUserName; // } // // @Override // public int getQuotedUserGroupId() { // return mQuotedUserGroupId; // } // // @Override // public int getQuotedInfractionGroupId() { // return mQuotedInfractionGroupId; // } // // @Override // public UnifiedThread getThread() { // return mThread; // } // // @Override // public String getAvatarUrl() { // return mResponseAvatar.getAvatarUrl(); // } // // @JsonProperty("avatar_url") // public void setAvatarUrl(final String avatarUrl) { // mResponseAvatar.setAvatarUrl(avatarUrl); // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(final Parcel dest, final int flags) { // mResponseAvatar.writeToParcel(dest, flags); // // dest.writeString(mPageText); // dest.writeInt(mDateLine); // dest.writeString(mPostId); // dest.writeString(mType); // dest.writeString(mUserId); // dest.writeString(mUserName); // dest.writeString(mQuotedUserId); // dest.writeString(mQuotedUserName); // dest.writeInt(mQuotedUserGroupId); // dest.writeInt(mQuotedInfractionGroupId); // dest.writeParcelable(mThread, 0); // } // } // Path: android/src/main/java/com/xda/one/api/model/response/container/ResponseQuoteContainer.java import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.xda.one.api.model.interfaces.container.QuoteContainer; import com.xda.one.api.model.response.ResponseQuote; import java.util.List; package com.xda.one.api.model.response.container; @JsonIgnoreProperties(ignoreUnknown = true) public class ResponseQuoteContainer implements QuoteContainer { @JsonProperty("results")
private List<ResponseQuote> mQuotes;
xda/XDA-One
android/src/main/java/com/xda/one/util/AccountUtils.java
// Path: android/src/main/java/com/xda/one/auth/XDAAccount.java // public class XDAAccount extends Account { // // public static final Creator<XDAAccount> CREATOR = new Creator<XDAAccount>() { // @Override // public XDAAccount createFromParcel(Parcel source) { // return new XDAAccount(source); // } // // @Override // public XDAAccount[] newArray(int size) { // return new XDAAccount[size]; // } // }; // // private final String mEmail; // // private final String mUserId; // // private final String mAvatarUrl; // // private final int mPmCount; // // private final int mQuoteCount; // // private final int mMentionCount; // // private final String mAuthToken; // // public XDAAccount(final String name, final String userId, final String email, // final String avatarUrl, final int pmCount, final int quoteCount, // final int mentionCount, final String authToken) { // super(name, "com.xda"); // mEmail = email; // mUserId = userId; // mAvatarUrl = avatarUrl; // mPmCount = pmCount; // mQuoteCount = quoteCount; // mMentionCount = mentionCount; // // mAuthToken = authToken; // } // // public XDAAccount(final Parcel source) { // super(source); // // mEmail = source.readString(); // mUserId = source.readString(); // mAvatarUrl = source.readString(); // mPmCount = source.readInt(); // mQuoteCount = source.readInt(); // mMentionCount = source.readInt(); // mAuthToken = source.readString(); // } // // public static XDAAccount fromProfile(final ResponseUserProfile profile) { // final ResponseUserProfileNotificationContainer notifications = profile.getNotifications(); // return new XDAAccount(profile.getUserName(), profile.getUserId(), profile.getEmail(), // profile.getAvatarUrl(), notifications.getPmUnread().getTotal(), // notifications.getDbTechQuoteCount().getTotal(), // notifications.getDbTechMetionCount().getTotal(), // RetrofitClient.getAuthToken()); // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // super.writeToParcel(dest, flags); // // dest.writeString(mEmail); // dest.writeString(mUserId); // dest.writeString(mAvatarUrl); // dest.writeInt(mPmCount); // dest.writeInt(mQuoteCount); // dest.writeInt(mMentionCount); // dest.writeString(mAuthToken); // } // // public String getEmail() { // return mEmail; // } // // public String getUserId() { // return mUserId; // } // // public String getAvatarUrl() { // return mAvatarUrl; // } // // public String getUserName() { // return name; // } // // public int getPmCount() { // return mPmCount; // } // // public int getQuoteCount() { // return mQuoteCount; // } // // public int getMentionCount() { // return mMentionCount; // } // // public String getAuthToken() { // return mAuthToken; // } // }
import com.xda.one.auth.XDAAccount; import android.content.Context; import android.content.SharedPreferences; import android.text.TextUtils; import static android.preference.PreferenceManager.getDefaultSharedPreferences;
package com.xda.one.util; public class AccountUtils { private static final String SELECTED_ACCOUNT_USERNAME = "selected_account_username"; private static final String SELECTED_ACCOUNT_USERID = "selected_account_userid"; private static final String SELECTED_ACCOUNT_EMAIL = "selected_account_email"; private static final String SELECTED_ACCOUNT_AVATAR = "selected_account_avatar"; private static final String SELECTED_ACCOUNT_PM_COUNT = "selected_account_pm_count"; private static final String SELECTED_ACCOUNT_QUOTE_COUNT = "selected_account_quote_count"; private static final String SELECTED_ACCOUNT_MENTION_COUNT = "selected_accont_mention_count"; private static final String SELECTED_ACCOUNT_TOKEN = "selected_account_token"; public static boolean isAccountAvailable(final Context context) { final SharedPreferences sharedPreferences = getDefaultSharedPreferences(context); return sharedPreferences.getString(SELECTED_ACCOUNT_USERNAME, null) != null; }
// Path: android/src/main/java/com/xda/one/auth/XDAAccount.java // public class XDAAccount extends Account { // // public static final Creator<XDAAccount> CREATOR = new Creator<XDAAccount>() { // @Override // public XDAAccount createFromParcel(Parcel source) { // return new XDAAccount(source); // } // // @Override // public XDAAccount[] newArray(int size) { // return new XDAAccount[size]; // } // }; // // private final String mEmail; // // private final String mUserId; // // private final String mAvatarUrl; // // private final int mPmCount; // // private final int mQuoteCount; // // private final int mMentionCount; // // private final String mAuthToken; // // public XDAAccount(final String name, final String userId, final String email, // final String avatarUrl, final int pmCount, final int quoteCount, // final int mentionCount, final String authToken) { // super(name, "com.xda"); // mEmail = email; // mUserId = userId; // mAvatarUrl = avatarUrl; // mPmCount = pmCount; // mQuoteCount = quoteCount; // mMentionCount = mentionCount; // // mAuthToken = authToken; // } // // public XDAAccount(final Parcel source) { // super(source); // // mEmail = source.readString(); // mUserId = source.readString(); // mAvatarUrl = source.readString(); // mPmCount = source.readInt(); // mQuoteCount = source.readInt(); // mMentionCount = source.readInt(); // mAuthToken = source.readString(); // } // // public static XDAAccount fromProfile(final ResponseUserProfile profile) { // final ResponseUserProfileNotificationContainer notifications = profile.getNotifications(); // return new XDAAccount(profile.getUserName(), profile.getUserId(), profile.getEmail(), // profile.getAvatarUrl(), notifications.getPmUnread().getTotal(), // notifications.getDbTechQuoteCount().getTotal(), // notifications.getDbTechMetionCount().getTotal(), // RetrofitClient.getAuthToken()); // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // super.writeToParcel(dest, flags); // // dest.writeString(mEmail); // dest.writeString(mUserId); // dest.writeString(mAvatarUrl); // dest.writeInt(mPmCount); // dest.writeInt(mQuoteCount); // dest.writeInt(mMentionCount); // dest.writeString(mAuthToken); // } // // public String getEmail() { // return mEmail; // } // // public String getUserId() { // return mUserId; // } // // public String getAvatarUrl() { // return mAvatarUrl; // } // // public String getUserName() { // return name; // } // // public int getPmCount() { // return mPmCount; // } // // public int getQuoteCount() { // return mQuoteCount; // } // // public int getMentionCount() { // return mMentionCount; // } // // public String getAuthToken() { // return mAuthToken; // } // } // Path: android/src/main/java/com/xda/one/util/AccountUtils.java import com.xda.one.auth.XDAAccount; import android.content.Context; import android.content.SharedPreferences; import android.text.TextUtils; import static android.preference.PreferenceManager.getDefaultSharedPreferences; package com.xda.one.util; public class AccountUtils { private static final String SELECTED_ACCOUNT_USERNAME = "selected_account_username"; private static final String SELECTED_ACCOUNT_USERID = "selected_account_userid"; private static final String SELECTED_ACCOUNT_EMAIL = "selected_account_email"; private static final String SELECTED_ACCOUNT_AVATAR = "selected_account_avatar"; private static final String SELECTED_ACCOUNT_PM_COUNT = "selected_account_pm_count"; private static final String SELECTED_ACCOUNT_QUOTE_COUNT = "selected_account_quote_count"; private static final String SELECTED_ACCOUNT_MENTION_COUNT = "selected_accont_mention_count"; private static final String SELECTED_ACCOUNT_TOKEN = "selected_account_token"; public static boolean isAccountAvailable(final Context context) { final SharedPreferences sharedPreferences = getDefaultSharedPreferences(context); return sharedPreferences.getString(SELECTED_ACCOUNT_USERNAME, null) != null; }
public static XDAAccount getAccount(final Context context) {
xda/XDA-One
android/src/main/java/com/xda/one/ui/thread/SubscribedThreadLoaderStrategy.java
// Path: android/src/main/java/com/xda/one/model/augmented/container/AugmentedUnifiedThreadContainer.java // public class AugmentedUnifiedThreadContainer implements UnifiedThreadContainer { // // private final UnifiedThreadContainer mUnifiedThreadContainer; // // private final List<AugmentedUnifiedThread> mAugmentedThreads; // // public AugmentedUnifiedThreadContainer(final UnifiedThreadContainer container, // final Context context) { // mUnifiedThreadContainer = container; // mAugmentedThreads = new ArrayList<>(mUnifiedThreadContainer.getThreads().size()); // // // Augment threads // for (final UnifiedThread thread : container.getThreads()) { // mAugmentedThreads.add(new AugmentedUnifiedThread(thread, context)); // } // } // // @Override // public List<AugmentedUnifiedThread> getThreads() { // return mAugmentedThreads; // } // // @Override // public int getTotalPages() { // return mUnifiedThreadContainer.getTotalPages(); // } // // @Override // public int getPerPage() { // return mUnifiedThreadContainer.getPerPage(); // } // // @Override // public int getCurrentPage() { // return mUnifiedThreadContainer.getCurrentPage(); // } // }
import com.xda.one.loader.SubscribedThreadLoader; import com.xda.one.model.augmented.container.AugmentedUnifiedThreadContainer; import android.content.Context; import android.os.Parcel; import android.os.Parcelable; import android.support.v4.content.Loader;
package com.xda.one.ui.thread; public class SubscribedThreadLoaderStrategy implements ThreadLoaderStrategy { public static final Parcelable.Creator<SubscribedThreadLoaderStrategy> CREATOR = new Parcelable.Creator<SubscribedThreadLoaderStrategy>() { public SubscribedThreadLoaderStrategy createFromParcel(Parcel in) { return new SubscribedThreadLoaderStrategy(); } public SubscribedThreadLoaderStrategy[] newArray(int size) { return new SubscribedThreadLoaderStrategy[size]; } }; @Override
// Path: android/src/main/java/com/xda/one/model/augmented/container/AugmentedUnifiedThreadContainer.java // public class AugmentedUnifiedThreadContainer implements UnifiedThreadContainer { // // private final UnifiedThreadContainer mUnifiedThreadContainer; // // private final List<AugmentedUnifiedThread> mAugmentedThreads; // // public AugmentedUnifiedThreadContainer(final UnifiedThreadContainer container, // final Context context) { // mUnifiedThreadContainer = container; // mAugmentedThreads = new ArrayList<>(mUnifiedThreadContainer.getThreads().size()); // // // Augment threads // for (final UnifiedThread thread : container.getThreads()) { // mAugmentedThreads.add(new AugmentedUnifiedThread(thread, context)); // } // } // // @Override // public List<AugmentedUnifiedThread> getThreads() { // return mAugmentedThreads; // } // // @Override // public int getTotalPages() { // return mUnifiedThreadContainer.getTotalPages(); // } // // @Override // public int getPerPage() { // return mUnifiedThreadContainer.getPerPage(); // } // // @Override // public int getCurrentPage() { // return mUnifiedThreadContainer.getCurrentPage(); // } // } // Path: android/src/main/java/com/xda/one/ui/thread/SubscribedThreadLoaderStrategy.java import com.xda.one.loader.SubscribedThreadLoader; import com.xda.one.model.augmented.container.AugmentedUnifiedThreadContainer; import android.content.Context; import android.os.Parcel; import android.os.Parcelable; import android.support.v4.content.Loader; package com.xda.one.ui.thread; public class SubscribedThreadLoaderStrategy implements ThreadLoaderStrategy { public static final Parcelable.Creator<SubscribedThreadLoaderStrategy> CREATOR = new Parcelable.Creator<SubscribedThreadLoaderStrategy>() { public SubscribedThreadLoaderStrategy createFromParcel(Parcel in) { return new SubscribedThreadLoaderStrategy(); } public SubscribedThreadLoaderStrategy[] newArray(int size) { return new SubscribedThreadLoaderStrategy[size]; } }; @Override
public Loader<AugmentedUnifiedThreadContainer> createLoader(final Context context,
xda/XDA-One
android/src/main/java/com/xda/one/model/augmented/container/AugmentedUnifiedThreadContainer.java
// Path: android/src/main/java/com/xda/one/api/model/interfaces/UnifiedThread.java // public interface UnifiedThread extends Parcelable { // // public String getThreadId(); // // public boolean isAttach(); // // public boolean hasAttachment(); // // public int getViews(); // // public long getLastPost(); // // public String getTitle(); // // public String getFirstPostContent(); // // public String getPostUsername(); // // public boolean isSticky(); // // public int getTotalPosts(); // // public int getLastPostId(); // // public String getLastPoster(); // // public int getFirstPostId(); // // public String getThreadSlug(); // // String getForumTitle(); // // public int getForumId(); // // public int getReplyCount(); // // public boolean isSubscribed(); // // public String getAvatarUrl(); // // public boolean isUnread(); // // boolean isOpen(); // // public String getWebUri(); // }
import com.xda.one.api.model.interfaces.UnifiedThread; import com.xda.one.api.model.interfaces.container.UnifiedThreadContainer; import com.xda.one.model.augmented.AugmentedUnifiedThread; import android.content.Context; import java.util.ArrayList; import java.util.List;
package com.xda.one.model.augmented.container; public class AugmentedUnifiedThreadContainer implements UnifiedThreadContainer { private final UnifiedThreadContainer mUnifiedThreadContainer; private final List<AugmentedUnifiedThread> mAugmentedThreads; public AugmentedUnifiedThreadContainer(final UnifiedThreadContainer container, final Context context) { mUnifiedThreadContainer = container; mAugmentedThreads = new ArrayList<>(mUnifiedThreadContainer.getThreads().size()); // Augment threads
// Path: android/src/main/java/com/xda/one/api/model/interfaces/UnifiedThread.java // public interface UnifiedThread extends Parcelable { // // public String getThreadId(); // // public boolean isAttach(); // // public boolean hasAttachment(); // // public int getViews(); // // public long getLastPost(); // // public String getTitle(); // // public String getFirstPostContent(); // // public String getPostUsername(); // // public boolean isSticky(); // // public int getTotalPosts(); // // public int getLastPostId(); // // public String getLastPoster(); // // public int getFirstPostId(); // // public String getThreadSlug(); // // String getForumTitle(); // // public int getForumId(); // // public int getReplyCount(); // // public boolean isSubscribed(); // // public String getAvatarUrl(); // // public boolean isUnread(); // // boolean isOpen(); // // public String getWebUri(); // } // Path: android/src/main/java/com/xda/one/model/augmented/container/AugmentedUnifiedThreadContainer.java import com.xda.one.api.model.interfaces.UnifiedThread; import com.xda.one.api.model.interfaces.container.UnifiedThreadContainer; import com.xda.one.model.augmented.AugmentedUnifiedThread; import android.content.Context; import java.util.ArrayList; import java.util.List; package com.xda.one.model.augmented.container; public class AugmentedUnifiedThreadContainer implements UnifiedThreadContainer { private final UnifiedThreadContainer mUnifiedThreadContainer; private final List<AugmentedUnifiedThread> mAugmentedThreads; public AugmentedUnifiedThreadContainer(final UnifiedThreadContainer container, final Context context) { mUnifiedThreadContainer = container; mAugmentedThreads = new ArrayList<>(mUnifiedThreadContainer.getThreads().size()); // Augment threads
for (final UnifiedThread thread : container.getThreads()) {
xda/XDA-One
android/src/main/java/com/xda/one/api/model/response/ResponseUserProfile.java
// Path: android/src/main/java/com/xda/one/api/model/response/container/ResponseUserProfileNotificationContainer.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class ResponseUserProfileNotificationContainer { // // @JsonProperty("pmunread") // private ResponseUserProfileNotification mPmUnread; // // @JsonProperty("friendreqcount") // private ResponseUserProfileNotification mFriendReqCount; // // @JsonProperty("socgroupreqcount") // private ResponseUserProfileNotification mSocGroupReqCount; // // @JsonProperty("socgroupinvitecount") // private ResponseUserProfileNotification mSocGroupInviteCount; // // @JsonProperty("pcunreadcount") // private ResponseUserProfileNotification mPcUnreadCount; // // @JsonProperty("pcmoderatedcount") // private ResponseUserProfileNotification mPcModeratedCount; // // @JsonProperty("gmmoderatedcount") // private ResponseUserProfileNotification mGmModeratedCount; // // @JsonProperty("dbtech_usertag_mentioncount") // private ResponseUserProfileNotification mDbTechMetionCount; // // @JsonProperty("dbtech_usertag_quotecount") // private ResponseUserProfileNotification mDebTechQuoteCount; // // @JsonProperty("devdbupdates") // private ResponseUserProfileNotification mDevDbUpdates; // // @JsonProperty("total") // private int mTotal; // // public ResponseUserProfileNotification getPmUnread() { // return mPmUnread; // } // // public ResponseUserProfileNotification getFriendReqCount() { // return mFriendReqCount; // } // // public ResponseUserProfileNotification getSocGroupReqCount() { // return mSocGroupReqCount; // } // // public ResponseUserProfileNotification getSocGroupInviteCount() { // return mSocGroupInviteCount; // } // // public ResponseUserProfileNotification getPcUnreadCount() { // return mPcUnreadCount; // } // // public ResponseUserProfileNotification getPcModeratedCount() { // return mPcModeratedCount; // } // // public ResponseUserProfileNotification getGmModeratedCount() { // return mGmModeratedCount; // } // // public ResponseUserProfileNotification getDbTechMetionCount() { // return mDbTechMetionCount; // } // // public ResponseUserProfileNotification getDbTechQuoteCount() { // return mDebTechQuoteCount; // } // // public ResponseUserProfileNotification getDevDbUpdates() { // return mDevDbUpdates; // } // // public int getTotal() { // return mTotal; // } // // }
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.xda.one.api.model.response.container.ResponseUserProfileNotificationContainer; import java.util.List;
package com.xda.one.api.model.response; @JsonIgnoreProperties(ignoreUnknown = true) public class ResponseUserProfile { private final ResponseAvatar mResponseAvatar = new ResponseAvatar(); @JsonProperty("userid") private String mUserId; @JsonProperty("signature") private String mSignature; @JsonProperty("username") private String mUserName; @JsonProperty("usertitle") private String mUserTitle; @JsonProperty("posts") private int mPosts; @JsonProperty("post_thanks_thanked_posts") private int mThankedPosts; @JsonProperty("post_thanks_thanked_times") private int mThankedTimes; @JsonProperty("devices") private List<ResponseUserProfileDevice> mDevices; @JsonProperty("email") private String mEmail; @JsonProperty("notifications")
// Path: android/src/main/java/com/xda/one/api/model/response/container/ResponseUserProfileNotificationContainer.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class ResponseUserProfileNotificationContainer { // // @JsonProperty("pmunread") // private ResponseUserProfileNotification mPmUnread; // // @JsonProperty("friendreqcount") // private ResponseUserProfileNotification mFriendReqCount; // // @JsonProperty("socgroupreqcount") // private ResponseUserProfileNotification mSocGroupReqCount; // // @JsonProperty("socgroupinvitecount") // private ResponseUserProfileNotification mSocGroupInviteCount; // // @JsonProperty("pcunreadcount") // private ResponseUserProfileNotification mPcUnreadCount; // // @JsonProperty("pcmoderatedcount") // private ResponseUserProfileNotification mPcModeratedCount; // // @JsonProperty("gmmoderatedcount") // private ResponseUserProfileNotification mGmModeratedCount; // // @JsonProperty("dbtech_usertag_mentioncount") // private ResponseUserProfileNotification mDbTechMetionCount; // // @JsonProperty("dbtech_usertag_quotecount") // private ResponseUserProfileNotification mDebTechQuoteCount; // // @JsonProperty("devdbupdates") // private ResponseUserProfileNotification mDevDbUpdates; // // @JsonProperty("total") // private int mTotal; // // public ResponseUserProfileNotification getPmUnread() { // return mPmUnread; // } // // public ResponseUserProfileNotification getFriendReqCount() { // return mFriendReqCount; // } // // public ResponseUserProfileNotification getSocGroupReqCount() { // return mSocGroupReqCount; // } // // public ResponseUserProfileNotification getSocGroupInviteCount() { // return mSocGroupInviteCount; // } // // public ResponseUserProfileNotification getPcUnreadCount() { // return mPcUnreadCount; // } // // public ResponseUserProfileNotification getPcModeratedCount() { // return mPcModeratedCount; // } // // public ResponseUserProfileNotification getGmModeratedCount() { // return mGmModeratedCount; // } // // public ResponseUserProfileNotification getDbTechMetionCount() { // return mDbTechMetionCount; // } // // public ResponseUserProfileNotification getDbTechQuoteCount() { // return mDebTechQuoteCount; // } // // public ResponseUserProfileNotification getDevDbUpdates() { // return mDevDbUpdates; // } // // public int getTotal() { // return mTotal; // } // // } // Path: android/src/main/java/com/xda/one/api/model/response/ResponseUserProfile.java import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.xda.one.api.model.response.container.ResponseUserProfileNotificationContainer; import java.util.List; package com.xda.one.api.model.response; @JsonIgnoreProperties(ignoreUnknown = true) public class ResponseUserProfile { private final ResponseAvatar mResponseAvatar = new ResponseAvatar(); @JsonProperty("userid") private String mUserId; @JsonProperty("signature") private String mSignature; @JsonProperty("username") private String mUserName; @JsonProperty("usertitle") private String mUserTitle; @JsonProperty("posts") private int mPosts; @JsonProperty("post_thanks_thanked_posts") private int mThankedPosts; @JsonProperty("post_thanks_thanked_times") private int mThankedTimes; @JsonProperty("devices") private List<ResponseUserProfileDevice> mDevices; @JsonProperty("email") private String mEmail; @JsonProperty("notifications")
private ResponseUserProfileNotificationContainer mNotifications;
xda/XDA-One
android/src/main/java/com/xda/one/api/model/interfaces/Message.java
// Path: android/src/main/java/com/xda/one/parser/TextDataStructure.java // public class TextDataStructure { // // private final ArrayList<Section> mSections; // // public TextDataStructure(final Spanned spanned) { // mSections = new ArrayList<>(); // // if (TextUtils.isEmpty(spanned)) { // return; // } // setupAllSections(spanned); // } // // private void setupAllSections(final Spanned spanned) { // final XDATagHandlers.QuoteTagHandler.QuoteSpan[] quoteSpans = spanned.getSpans(0, // spanned.length(), XDATagHandlers.QuoteTagHandler.QuoteSpan.class); // int position = 0; // for (XDATagHandlers.QuoteTagHandler.QuoteSpan span : quoteSpans) { // int start = spanned.getSpanStart(span); // if (position < start) { // setupNormalSection(new SpannableStringBuilder(spanned, position, start)); // } else if (position > start) { // // In this case this item is the parent of the previous quote span // final Section previous = mSections.get(mSections.size() - 1); // previous.setEmbedded(true); // start = position; // } // position = spanned.getSpanEnd(span); // setupQuoteSection(new SpannableStringBuilder(spanned, start, position), // span.getUserId()); // } // if (position < spanned.length()) { // setupNormalSection(new SpannableStringBuilder(spanned, position, spanned.length())); // } // } // // private void setupNormalSection(final Spanned spanned) { // final Section section = new Section(SectionType.NORMAL); // setupImageSections(section, spanned, new Callback() { // @Override // public void setupOther(int start, int end) { // final Text text = new Text(new SpannableStringBuilder(spanned, start, end)); // section.addItem(text); // } // }); // mSections.add(section); // } // // private void setupQuoteSection(final Spanned spanned, final String userId) { // final Section section = new Section(SectionType.QUOTE); // section.setUserId(userId); // setupImageSections(section, spanned, new Callback() { // @Override // public void setupOther(int start, int end) { // final Text text = new Text(new SpannableStringBuilder(spanned, start, end)); // section.addItem(text); // } // }); // mSections.add(section); // } // // private void setupImageSections(final Section section, final Spanned spanned, // final Callback callback) { // final XDATagHandlers.ImageHandler.ImageSpan[] imageSpans = spanned.getSpans(0, // spanned.length(), XDATagHandlers.ImageHandler.ImageSpan.class); // int position = 0; // for (int i = imageSpans.length - 1; i >= 0; i--) { // final XDATagHandlers.ImageHandler.ImageSpan span = imageSpans[i]; // final int start = spanned.getSpanStart(span); // if (position < start) { // callback.setupOther(position, start); // } // final Image image = new Image(span.getSrc()); // section.addItem(image); // // position = spanned.getSpanEnd(span); // } // if (position < spanned.length()) { // callback.setupOther(position, spanned.length()); // } // } // // public List<Section> getSections() { // return Collections.unmodifiableList(mSections); // } // // public enum ItemType { // TEXT, // IMAGE // } // // public enum SectionType { // NORMAL, // QUOTE // } // // public interface Item { // // public ItemType getType(); // // public CharSequence getId(); // } // // private interface Callback { // // public void setupOther(int start, int end); // } // // public class Section { // // private final SectionType mType; // // private final List<Item> mItems; // // private boolean mEmbedded; // // private String mUserId; // // public Section(final SectionType type) { // mType = type; // mItems = new ArrayList<>(); // } // // public SectionType getType() { // return mType; // } // // public List<Item> getItems() { // return mItems; // } // // private void addItem(final Item image) { // mItems.add(image); // } // // public boolean isEmbedded() { // return mEmbedded; // } // // public void setEmbedded(boolean embedded) { // mEmbedded = embedded; // } // // public void setUserId(final String userId) { // mUserId = userId; // } // // public String getUsernamePostId() { // return mUserId; // } // } // // public class Text implements Item { // // private final Spanned mText; // // public Text(final Spanned text) { // mText = text; // } // // @Override // public ItemType getType() { // return ItemType.TEXT; // } // // @Override // public CharSequence getId() { // return mText; // } // } // // public class Image implements Item { // // private final String mSource; // // public Image(final String source) { // mSource = source; // } // // @Override // public ItemType getType() { // return ItemType.IMAGE; // } // // @Override // public CharSequence getId() { // return mSource; // } // } // }
import com.xda.one.parser.TextDataStructure; import android.os.Parcelable;
package com.xda.one.api.model.interfaces; public interface Message extends Parcelable { public int getPmId(); public String getFromUserId(); public String getFromUserName(); public String getTitle(); public CharSequence getMessageContent(); public long getDate(); public boolean isMessageUnread(); String getToUserArray(); boolean isShowSignature(); boolean isAllowSmilie(); public String getAvatarUrl(); public String getSubMessage();
// Path: android/src/main/java/com/xda/one/parser/TextDataStructure.java // public class TextDataStructure { // // private final ArrayList<Section> mSections; // // public TextDataStructure(final Spanned spanned) { // mSections = new ArrayList<>(); // // if (TextUtils.isEmpty(spanned)) { // return; // } // setupAllSections(spanned); // } // // private void setupAllSections(final Spanned spanned) { // final XDATagHandlers.QuoteTagHandler.QuoteSpan[] quoteSpans = spanned.getSpans(0, // spanned.length(), XDATagHandlers.QuoteTagHandler.QuoteSpan.class); // int position = 0; // for (XDATagHandlers.QuoteTagHandler.QuoteSpan span : quoteSpans) { // int start = spanned.getSpanStart(span); // if (position < start) { // setupNormalSection(new SpannableStringBuilder(spanned, position, start)); // } else if (position > start) { // // In this case this item is the parent of the previous quote span // final Section previous = mSections.get(mSections.size() - 1); // previous.setEmbedded(true); // start = position; // } // position = spanned.getSpanEnd(span); // setupQuoteSection(new SpannableStringBuilder(spanned, start, position), // span.getUserId()); // } // if (position < spanned.length()) { // setupNormalSection(new SpannableStringBuilder(spanned, position, spanned.length())); // } // } // // private void setupNormalSection(final Spanned spanned) { // final Section section = new Section(SectionType.NORMAL); // setupImageSections(section, spanned, new Callback() { // @Override // public void setupOther(int start, int end) { // final Text text = new Text(new SpannableStringBuilder(spanned, start, end)); // section.addItem(text); // } // }); // mSections.add(section); // } // // private void setupQuoteSection(final Spanned spanned, final String userId) { // final Section section = new Section(SectionType.QUOTE); // section.setUserId(userId); // setupImageSections(section, spanned, new Callback() { // @Override // public void setupOther(int start, int end) { // final Text text = new Text(new SpannableStringBuilder(spanned, start, end)); // section.addItem(text); // } // }); // mSections.add(section); // } // // private void setupImageSections(final Section section, final Spanned spanned, // final Callback callback) { // final XDATagHandlers.ImageHandler.ImageSpan[] imageSpans = spanned.getSpans(0, // spanned.length(), XDATagHandlers.ImageHandler.ImageSpan.class); // int position = 0; // for (int i = imageSpans.length - 1; i >= 0; i--) { // final XDATagHandlers.ImageHandler.ImageSpan span = imageSpans[i]; // final int start = spanned.getSpanStart(span); // if (position < start) { // callback.setupOther(position, start); // } // final Image image = new Image(span.getSrc()); // section.addItem(image); // // position = spanned.getSpanEnd(span); // } // if (position < spanned.length()) { // callback.setupOther(position, spanned.length()); // } // } // // public List<Section> getSections() { // return Collections.unmodifiableList(mSections); // } // // public enum ItemType { // TEXT, // IMAGE // } // // public enum SectionType { // NORMAL, // QUOTE // } // // public interface Item { // // public ItemType getType(); // // public CharSequence getId(); // } // // private interface Callback { // // public void setupOther(int start, int end); // } // // public class Section { // // private final SectionType mType; // // private final List<Item> mItems; // // private boolean mEmbedded; // // private String mUserId; // // public Section(final SectionType type) { // mType = type; // mItems = new ArrayList<>(); // } // // public SectionType getType() { // return mType; // } // // public List<Item> getItems() { // return mItems; // } // // private void addItem(final Item image) { // mItems.add(image); // } // // public boolean isEmbedded() { // return mEmbedded; // } // // public void setEmbedded(boolean embedded) { // mEmbedded = embedded; // } // // public void setUserId(final String userId) { // mUserId = userId; // } // // public String getUsernamePostId() { // return mUserId; // } // } // // public class Text implements Item { // // private final Spanned mText; // // public Text(final Spanned text) { // mText = text; // } // // @Override // public ItemType getType() { // return ItemType.TEXT; // } // // @Override // public CharSequence getId() { // return mText; // } // } // // public class Image implements Item { // // private final String mSource; // // public Image(final String source) { // mSource = source; // } // // @Override // public ItemType getType() { // return ItemType.IMAGE; // } // // @Override // public CharSequence getId() { // return mSource; // } // } // } // Path: android/src/main/java/com/xda/one/api/model/interfaces/Message.java import com.xda.one.parser.TextDataStructure; import android.os.Parcelable; package com.xda.one.api.model.interfaces; public interface Message extends Parcelable { public int getPmId(); public String getFromUserId(); public String getFromUserName(); public String getTitle(); public CharSequence getMessageContent(); public long getDate(); public boolean isMessageUnread(); String getToUserArray(); boolean isShowSignature(); boolean isAllowSmilie(); public String getAvatarUrl(); public String getSubMessage();
public TextDataStructure getTextDataStructure();
xda/XDA-One
android/src/main/java/com/xda/one/ui/ThreadAdapter.java
// Path: android/src/main/java/com/xda/one/util/Utils.java // public class Utils { // // public static String handleRetrofitErrorQuietly(final RetrofitError error) { // error.printStackTrace(); // // InputStream inputStream = null; // try { // if (error.isNetworkError()) { // Log.e("XDA-ONE", "Network error happened."); // } else { // final TypedInput body = error.getResponse().getBody(); // if (body == null) { // Log.e("XDA-ONE", "Unable to retrieve body"); // return null; // } // inputStream = body.in(); // // final String result = IOUtils.toString(inputStream); // Log.e("XDA-ONE", result); // return result; // } // } catch (IOException e) { // e.printStackTrace(); // } finally { // IOUtils.closeQuietly(inputStream); // } // return null; // } // // public static <T> int getCollectionSize(final Collection<T> collection) { // return collection == null ? 0 : collection.size(); // } // // public static boolean isCollectionEmpty(final Collection collection) { // return collection == null || collection.isEmpty(); // } // // public static CharSequence getRelativeDate(final Context context, final long dateline) { // return DateUtils.getRelativeDateTimeString(context, dateline, // DateUtils.SECOND_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, // DateUtils.FORMAT_NUMERIC_DATE); // } // }
import com.squareup.picasso.Picasso; import com.xda.one.R; import com.xda.one.model.augmented.AugmentedUnifiedThread; import com.xda.one.ui.helper.ActionModeHelper; import com.xda.one.util.Utils; import android.content.Context; import android.graphics.Typeface; import android.support.v7.widget.RecyclerView; import android.text.Html; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.TextView; import java.text.NumberFormat; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Locale;
public void onBindViewHolder(final NormalThreadViewHolder holder, final int position) { if (getItemViewType(position) == FOOTER_VIEW_TYPE) { return; } final AugmentedUnifiedThread thread = getThread(position); // Set the click listener holder.container.setOnClickListener(mViewClickListener); holder.container.setOnLongClickListener(mLongClickListener); mActionModeHelper.updateActivatedState(holder.container, position); Picasso.with(mContext) .load(thread.getAvatarUrl()) .placeholder(R.drawable.account_circle) .error(R.drawable.account_circle) .into(holder.avatarView); holder.userNameView.setText(thread.getPostUsername()); holder.stickyView.setVisibility(thread.isSticky() ? View.VISIBLE : View.GONE); holder.lockedView.setVisibility(thread.isOpen() ? View.GONE : View.VISIBLE); holder.titleView.setText(Html.fromHtml(thread.getTitle())); holder.titleView.setTypeface(null, thread.isUnread() ? Typeface.BOLD : Typeface.NORMAL); holder.textView.setText(thread.getSubPageText()); holder.replyCount.setText(mNumberFormat.format(thread.getReplyCount())); holder.lastPostTimeView
// Path: android/src/main/java/com/xda/one/util/Utils.java // public class Utils { // // public static String handleRetrofitErrorQuietly(final RetrofitError error) { // error.printStackTrace(); // // InputStream inputStream = null; // try { // if (error.isNetworkError()) { // Log.e("XDA-ONE", "Network error happened."); // } else { // final TypedInput body = error.getResponse().getBody(); // if (body == null) { // Log.e("XDA-ONE", "Unable to retrieve body"); // return null; // } // inputStream = body.in(); // // final String result = IOUtils.toString(inputStream); // Log.e("XDA-ONE", result); // return result; // } // } catch (IOException e) { // e.printStackTrace(); // } finally { // IOUtils.closeQuietly(inputStream); // } // return null; // } // // public static <T> int getCollectionSize(final Collection<T> collection) { // return collection == null ? 0 : collection.size(); // } // // public static boolean isCollectionEmpty(final Collection collection) { // return collection == null || collection.isEmpty(); // } // // public static CharSequence getRelativeDate(final Context context, final long dateline) { // return DateUtils.getRelativeDateTimeString(context, dateline, // DateUtils.SECOND_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, // DateUtils.FORMAT_NUMERIC_DATE); // } // } // Path: android/src/main/java/com/xda/one/ui/ThreadAdapter.java import com.squareup.picasso.Picasso; import com.xda.one.R; import com.xda.one.model.augmented.AugmentedUnifiedThread; import com.xda.one.ui.helper.ActionModeHelper; import com.xda.one.util.Utils; import android.content.Context; import android.graphics.Typeface; import android.support.v7.widget.RecyclerView; import android.text.Html; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.TextView; import java.text.NumberFormat; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Locale; public void onBindViewHolder(final NormalThreadViewHolder holder, final int position) { if (getItemViewType(position) == FOOTER_VIEW_TYPE) { return; } final AugmentedUnifiedThread thread = getThread(position); // Set the click listener holder.container.setOnClickListener(mViewClickListener); holder.container.setOnLongClickListener(mLongClickListener); mActionModeHelper.updateActivatedState(holder.container, position); Picasso.with(mContext) .load(thread.getAvatarUrl()) .placeholder(R.drawable.account_circle) .error(R.drawable.account_circle) .into(holder.avatarView); holder.userNameView.setText(thread.getPostUsername()); holder.stickyView.setVisibility(thread.isSticky() ? View.VISIBLE : View.GONE); holder.lockedView.setVisibility(thread.isOpen() ? View.GONE : View.VISIBLE); holder.titleView.setText(Html.fromHtml(thread.getTitle())); holder.titleView.setTypeface(null, thread.isUnread() ? Typeface.BOLD : Typeface.NORMAL); holder.textView.setText(thread.getSubPageText()); holder.replyCount.setText(mNumberFormat.format(thread.getReplyCount())); holder.lastPostTimeView
.setText(Utils.getRelativeDate(mContext, thread.getLastPost()));
xda/XDA-One
android/src/main/java/com/xda/one/api/misc/Result.java
// Path: android/src/main/java/com/xda/one/api/retrofit/RetrofitClient.java // public static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
import com.fasterxml.jackson.databind.JsonNode; import org.apache.commons.io.IOUtils; import java.io.IOException; import java.io.InputStream; import retrofit.client.Response; import static com.xda.one.api.retrofit.RetrofitClient.OBJECT_MAPPER;
public Result(final boolean success) { mSuccess = success; } public Result(final String message) { mMessage = message; } public static Result parseResultFromResponse(final Response response) { InputStream inputStream = null; try { inputStream = response.getBody().in(); final String output = IOUtils.toString(inputStream); return Result.parseResultFromString(output); } catch (IOException | NullPointerException e) { e.printStackTrace(); } finally { IOUtils.closeQuietly(inputStream); } return null; } public static Result parseResultFromString(final String line) { if (line == null) { return null; } final Result result; try {
// Path: android/src/main/java/com/xda/one/api/retrofit/RetrofitClient.java // public static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); // Path: android/src/main/java/com/xda/one/api/misc/Result.java import com.fasterxml.jackson.databind.JsonNode; import org.apache.commons.io.IOUtils; import java.io.IOException; import java.io.InputStream; import retrofit.client.Response; import static com.xda.one.api.retrofit.RetrofitClient.OBJECT_MAPPER; public Result(final boolean success) { mSuccess = success; } public Result(final String message) { mMessage = message; } public static Result parseResultFromResponse(final Response response) { InputStream inputStream = null; try { inputStream = response.getBody().in(); final String output = IOUtils.toString(inputStream); return Result.parseResultFromString(output); } catch (IOException | NullPointerException e) { e.printStackTrace(); } finally { IOUtils.closeQuietly(inputStream); } return null; } public static Result parseResultFromString(final String line) { if (line == null) { return null; } final Result result; try {
final JsonNode error = OBJECT_MAPPER.readTree(line).get(ERROR);
xda/XDA-One
android/src/main/java/com/xda/one/ui/thread/ParticipatedThreadLoaderStrategy.java
// Path: android/src/main/java/com/xda/one/model/augmented/container/AugmentedUnifiedThreadContainer.java // public class AugmentedUnifiedThreadContainer implements UnifiedThreadContainer { // // private final UnifiedThreadContainer mUnifiedThreadContainer; // // private final List<AugmentedUnifiedThread> mAugmentedThreads; // // public AugmentedUnifiedThreadContainer(final UnifiedThreadContainer container, // final Context context) { // mUnifiedThreadContainer = container; // mAugmentedThreads = new ArrayList<>(mUnifiedThreadContainer.getThreads().size()); // // // Augment threads // for (final UnifiedThread thread : container.getThreads()) { // mAugmentedThreads.add(new AugmentedUnifiedThread(thread, context)); // } // } // // @Override // public List<AugmentedUnifiedThread> getThreads() { // return mAugmentedThreads; // } // // @Override // public int getTotalPages() { // return mUnifiedThreadContainer.getTotalPages(); // } // // @Override // public int getPerPage() { // return mUnifiedThreadContainer.getPerPage(); // } // // @Override // public int getCurrentPage() { // return mUnifiedThreadContainer.getCurrentPage(); // } // }
import com.xda.one.loader.ParticipatedThreadLoader; import com.xda.one.model.augmented.container.AugmentedUnifiedThreadContainer; import android.content.Context; import android.os.Parcel; import android.os.Parcelable; import android.support.v4.content.Loader;
package com.xda.one.ui.thread; public class ParticipatedThreadLoaderStrategy implements ThreadLoaderStrategy { public static final Parcelable.Creator<ParticipatedThreadLoaderStrategy> CREATOR = new Parcelable.Creator<ParticipatedThreadLoaderStrategy>() { public ParticipatedThreadLoaderStrategy createFromParcel(Parcel in) { return new ParticipatedThreadLoaderStrategy(); } public ParticipatedThreadLoaderStrategy[] newArray(int size) { return new ParticipatedThreadLoaderStrategy[size]; } }; @Override
// Path: android/src/main/java/com/xda/one/model/augmented/container/AugmentedUnifiedThreadContainer.java // public class AugmentedUnifiedThreadContainer implements UnifiedThreadContainer { // // private final UnifiedThreadContainer mUnifiedThreadContainer; // // private final List<AugmentedUnifiedThread> mAugmentedThreads; // // public AugmentedUnifiedThreadContainer(final UnifiedThreadContainer container, // final Context context) { // mUnifiedThreadContainer = container; // mAugmentedThreads = new ArrayList<>(mUnifiedThreadContainer.getThreads().size()); // // // Augment threads // for (final UnifiedThread thread : container.getThreads()) { // mAugmentedThreads.add(new AugmentedUnifiedThread(thread, context)); // } // } // // @Override // public List<AugmentedUnifiedThread> getThreads() { // return mAugmentedThreads; // } // // @Override // public int getTotalPages() { // return mUnifiedThreadContainer.getTotalPages(); // } // // @Override // public int getPerPage() { // return mUnifiedThreadContainer.getPerPage(); // } // // @Override // public int getCurrentPage() { // return mUnifiedThreadContainer.getCurrentPage(); // } // } // Path: android/src/main/java/com/xda/one/ui/thread/ParticipatedThreadLoaderStrategy.java import com.xda.one.loader.ParticipatedThreadLoader; import com.xda.one.model.augmented.container.AugmentedUnifiedThreadContainer; import android.content.Context; import android.os.Parcel; import android.os.Parcelable; import android.support.v4.content.Loader; package com.xda.one.ui.thread; public class ParticipatedThreadLoaderStrategy implements ThreadLoaderStrategy { public static final Parcelable.Creator<ParticipatedThreadLoaderStrategy> CREATOR = new Parcelable.Creator<ParticipatedThreadLoaderStrategy>() { public ParticipatedThreadLoaderStrategy createFromParcel(Parcel in) { return new ParticipatedThreadLoaderStrategy(); } public ParticipatedThreadLoaderStrategy[] newArray(int size) { return new ParticipatedThreadLoaderStrategy[size]; } }; @Override
public Loader<AugmentedUnifiedThreadContainer> createLoader(final Context context,
xda/XDA-One
android/src/main/java/com/xda/one/ui/PostFragmentAdapter.java
// Path: android/src/main/java/com/xda/one/api/model/interfaces/UnifiedThread.java // public interface UnifiedThread extends Parcelable { // // public String getThreadId(); // // public boolean isAttach(); // // public boolean hasAttachment(); // // public int getViews(); // // public long getLastPost(); // // public String getTitle(); // // public String getFirstPostContent(); // // public String getPostUsername(); // // public boolean isSticky(); // // public int getTotalPosts(); // // public int getLastPostId(); // // public String getLastPoster(); // // public int getFirstPostId(); // // public String getThreadSlug(); // // String getForumTitle(); // // public int getForumId(); // // public int getReplyCount(); // // public boolean isSubscribed(); // // public String getAvatarUrl(); // // public boolean isUnread(); // // boolean isOpen(); // // public String getWebUri(); // }
import com.xda.one.api.model.interfaces.UnifiedThread; import com.xda.one.api.model.response.container.ResponsePostContainer; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentStatePagerAdapter;
package com.xda.one.ui; public class PostFragmentAdapter extends FragmentStatePagerAdapter { private final int mCount; private ResponsePostContainer mContainerArgument;
// Path: android/src/main/java/com/xda/one/api/model/interfaces/UnifiedThread.java // public interface UnifiedThread extends Parcelable { // // public String getThreadId(); // // public boolean isAttach(); // // public boolean hasAttachment(); // // public int getViews(); // // public long getLastPost(); // // public String getTitle(); // // public String getFirstPostContent(); // // public String getPostUsername(); // // public boolean isSticky(); // // public int getTotalPosts(); // // public int getLastPostId(); // // public String getLastPoster(); // // public int getFirstPostId(); // // public String getThreadSlug(); // // String getForumTitle(); // // public int getForumId(); // // public int getReplyCount(); // // public boolean isSubscribed(); // // public String getAvatarUrl(); // // public boolean isUnread(); // // boolean isOpen(); // // public String getWebUri(); // } // Path: android/src/main/java/com/xda/one/ui/PostFragmentAdapter.java import com.xda.one.api.model.interfaces.UnifiedThread; import com.xda.one.api.model.response.container.ResponsePostContainer; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentStatePagerAdapter; package com.xda.one.ui; public class PostFragmentAdapter extends FragmentStatePagerAdapter { private final int mCount; private ResponsePostContainer mContainerArgument;
private UnifiedThread mUnifiedThread;
xda/XDA-One
android/src/main/java/com/xda/one/ui/listener/RecyclerEndHelper.java
// Path: android/src/main/java/android/support/v7/widget/XDALinerLayoutManager.java // public class XDALinerLayoutManager extends LinearLayoutManager { // // private boolean mListEnd = true; // // public XDALinerLayoutManager(final Context context) { // super(context); // } // // public XDALinerLayoutManager(final Context context, final int orientation, // final boolean reverseLayout) { // super(context, orientation, reverseLayout); // } // // @Override // int scrollBy(final int dy, final RecyclerView.Recycler recycler, // final RecyclerView.State state) { // int scrolled = super.scrollBy(dy, recycler, state); // mListEnd = dy > 0 && dy > scrolled; // return scrolled; // } // // public boolean isListEnd() { // return mListEnd; // } // }
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.XDALinerLayoutManager;
package com.xda.one.ui.listener; public class RecyclerEndHelper extends RecyclerView.OnScrollListener { private final Callback mCallback;
// Path: android/src/main/java/android/support/v7/widget/XDALinerLayoutManager.java // public class XDALinerLayoutManager extends LinearLayoutManager { // // private boolean mListEnd = true; // // public XDALinerLayoutManager(final Context context) { // super(context); // } // // public XDALinerLayoutManager(final Context context, final int orientation, // final boolean reverseLayout) { // super(context, orientation, reverseLayout); // } // // @Override // int scrollBy(final int dy, final RecyclerView.Recycler recycler, // final RecyclerView.State state) { // int scrolled = super.scrollBy(dy, recycler, state); // mListEnd = dy > 0 && dy > scrolled; // return scrolled; // } // // public boolean isListEnd() { // return mListEnd; // } // } // Path: android/src/main/java/com/xda/one/ui/listener/RecyclerEndHelper.java import android.support.v7.widget.RecyclerView; import android.support.v7.widget.XDALinerLayoutManager; package com.xda.one.ui.listener; public class RecyclerEndHelper extends RecyclerView.OnScrollListener { private final Callback mCallback;
private XDALinerLayoutManager mLayoutManager;
xda/XDA-One
android/src/main/java/com/xda/one/api/model/interfaces/News.java
// Path: android/src/main/java/com/xda/one/api/model/response/ResponseAttachment.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class ResponseAttachment implements Parcelable { // // public static final Parcelable.Creator<ResponseAttachment> CREATOR // = new Parcelable.Creator<ResponseAttachment>() { // @Override // public ResponseAttachment createFromParcel(Parcel source) { // return new ResponseAttachment(source); // } // // @Override // public ResponseAttachment[] newArray(int size) { // return new ResponseAttachment[size]; // } // }; // // @JsonProperty(value = "dateline") // private long mDateLine; // // @JsonProperty(value = "thumbnail_dateline") // private long mThumbnailDateLine; // // @JsonProperty(value = "filename") // private String mFileName; // // @JsonProperty(value = "filesize") // private float mFileSize; // // @JsonProperty(value = "visible") // private int mVisible; // // @JsonProperty(value = "attachmentid") // private int mAttachmentId; // // @JsonProperty(value = "counter") // private int mCounter; // // @JsonProperty(value = "postid") // private int mPostId; // // @JsonProperty(value = "hasthumbnail") // private int mHasThumbnail; // // @JsonProperty(value = "thumbnail_filesize") // private int mThumbnailFileSize; // // @JsonProperty(value = "build_thumbnail") // private int mBuildThumbnail; // // @JsonProperty(value = "newwindow") // private int mNewWindow; // // @JsonProperty(value = "attachment_url") // private String mAttachmentUrl; // // public ResponseAttachment() { // } // // private ResponseAttachment(final Parcel in) { // mDateLine = in.readLong(); // mThumbnailDateLine = in.readLong(); // mFileName = in.readString(); // mFileSize = in.readFloat(); // mVisible = in.readInt(); // mAttachmentId = in.readInt(); // mCounter = in.readInt(); // mPostId = in.readInt(); // mHasThumbnail = in.readInt(); // mThumbnailFileSize = in.readInt(); // mBuildThumbnail = in.readInt(); // mNewWindow = in.readInt(); // mAttachmentUrl = in.readString(); // } // // public long getDateLine() { // return mDateLine; // } // // public long getThumbnailDateLine() { // return mThumbnailDateLine; // } // // public String getFileName() { // return mFileName; // } // // public float getFileSize() { // return mFileSize; // } // // public boolean isVisible() { // return mVisible != 0; // } // // public int getAttachmentId() { // return mAttachmentId; // } // // public int getCounter() { // return mCounter; // } // // public int getPostId() { // return mPostId; // } // // public boolean hasThumbnail() { // return mHasThumbnail != 0; // } // // public int getThumbnailFileSize() { // return mThumbnailFileSize; // } // // public int getBuildThumbnail() { // return mBuildThumbnail; // } // // public boolean isNewWindow() { // return mNewWindow != 0; // } // // public String getAttachmentUrl() { // return mAttachmentUrl; // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeLong(mDateLine); // dest.writeLong(mThumbnailDateLine); // dest.writeString(mFileName); // dest.writeFloat(mFileSize); // dest.writeInt(mVisible); // dest.writeInt(mAttachmentId); // dest.writeInt(mCounter); // dest.writeInt(mPostId); // dest.writeInt(mHasThumbnail); // dest.writeInt(mThumbnailFileSize); // dest.writeInt(mBuildThumbnail); // dest.writeInt(mNewWindow); // dest.writeString(mAttachmentUrl); // } // }
import com.xda.one.api.model.response.ResponseAttachment; import android.os.Parcelable; import java.util.List;
package com.xda.one.api.model.interfaces; public interface News extends Parcelable { public int getTitle(); public int getContent(); public String getUrl(); public String getThumb(); public String getPageText(); public String getUserName(); public long getDateline();
// Path: android/src/main/java/com/xda/one/api/model/response/ResponseAttachment.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class ResponseAttachment implements Parcelable { // // public static final Parcelable.Creator<ResponseAttachment> CREATOR // = new Parcelable.Creator<ResponseAttachment>() { // @Override // public ResponseAttachment createFromParcel(Parcel source) { // return new ResponseAttachment(source); // } // // @Override // public ResponseAttachment[] newArray(int size) { // return new ResponseAttachment[size]; // } // }; // // @JsonProperty(value = "dateline") // private long mDateLine; // // @JsonProperty(value = "thumbnail_dateline") // private long mThumbnailDateLine; // // @JsonProperty(value = "filename") // private String mFileName; // // @JsonProperty(value = "filesize") // private float mFileSize; // // @JsonProperty(value = "visible") // private int mVisible; // // @JsonProperty(value = "attachmentid") // private int mAttachmentId; // // @JsonProperty(value = "counter") // private int mCounter; // // @JsonProperty(value = "postid") // private int mPostId; // // @JsonProperty(value = "hasthumbnail") // private int mHasThumbnail; // // @JsonProperty(value = "thumbnail_filesize") // private int mThumbnailFileSize; // // @JsonProperty(value = "build_thumbnail") // private int mBuildThumbnail; // // @JsonProperty(value = "newwindow") // private int mNewWindow; // // @JsonProperty(value = "attachment_url") // private String mAttachmentUrl; // // public ResponseAttachment() { // } // // private ResponseAttachment(final Parcel in) { // mDateLine = in.readLong(); // mThumbnailDateLine = in.readLong(); // mFileName = in.readString(); // mFileSize = in.readFloat(); // mVisible = in.readInt(); // mAttachmentId = in.readInt(); // mCounter = in.readInt(); // mPostId = in.readInt(); // mHasThumbnail = in.readInt(); // mThumbnailFileSize = in.readInt(); // mBuildThumbnail = in.readInt(); // mNewWindow = in.readInt(); // mAttachmentUrl = in.readString(); // } // // public long getDateLine() { // return mDateLine; // } // // public long getThumbnailDateLine() { // return mThumbnailDateLine; // } // // public String getFileName() { // return mFileName; // } // // public float getFileSize() { // return mFileSize; // } // // public boolean isVisible() { // return mVisible != 0; // } // // public int getAttachmentId() { // return mAttachmentId; // } // // public int getCounter() { // return mCounter; // } // // public int getPostId() { // return mPostId; // } // // public boolean hasThumbnail() { // return mHasThumbnail != 0; // } // // public int getThumbnailFileSize() { // return mThumbnailFileSize; // } // // public int getBuildThumbnail() { // return mBuildThumbnail; // } // // public boolean isNewWindow() { // return mNewWindow != 0; // } // // public String getAttachmentUrl() { // return mAttachmentUrl; // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeLong(mDateLine); // dest.writeLong(mThumbnailDateLine); // dest.writeString(mFileName); // dest.writeFloat(mFileSize); // dest.writeInt(mVisible); // dest.writeInt(mAttachmentId); // dest.writeInt(mCounter); // dest.writeInt(mPostId); // dest.writeInt(mHasThumbnail); // dest.writeInt(mThumbnailFileSize); // dest.writeInt(mBuildThumbnail); // dest.writeInt(mNewWindow); // dest.writeString(mAttachmentUrl); // } // } // Path: android/src/main/java/com/xda/one/api/model/interfaces/News.java import com.xda.one.api.model.response.ResponseAttachment; import android.os.Parcelable; import java.util.List; package com.xda.one.api.model.interfaces; public interface News extends Parcelable { public int getTitle(); public int getContent(); public String getUrl(); public String getThumb(); public String getPageText(); public String getUserName(); public long getDateline();
public List<ResponseAttachment> getAttachments();
xda/XDA-One
android/src/main/java/com/xda/one/db/ForumDbHelper.java
// Path: android/src/main/java/com/xda/one/api/model/interfaces/Forum.java // public interface Forum extends Parcelable { // // public String getTitle(); // // public int getForumId(); // // public int getParentId(); // // public String getForumSlug(); // // public boolean isSubscribed(); // // public void setSubscribed(boolean subs); // // public String getImageUrl(); // // public boolean hasChildren(); // // public String getWebUri(); // // public boolean canContainThreads(); // } // // Path: android/src/main/java/com/xda/one/db/ForumDbHelper.java // public static abstract class ForumEntry implements BaseColumns { // // public static final String COLUMN_NAME_TITLE = "title"; // // public static final String COLUMN_NAME_CONTENT = "content"; // // public static final String COLUMN_NAME_FORUMID = "forumid"; // // public static final String COLUMN_NAME_PARENTID = "parentid"; // // public static final String COLUMN_NAME_FORUMSLUG = "forumslug"; // // public static final String COLUMN_NAME_SUBSCRIBED = "subscribed"; // // public static final String COLUMN_NAME_IMAGE = "image"; // // public static final String COLUMN_NAME_SEARCHABLE = "searchable"; // // public static final String COLUMN_NAME_CAN_CONTAIN_THREADS = "can_contain_threads"; // // public static final String COLUMN_NAME_WEB_URI = "web_uri"; // // public static final String COLUMN_NAME_CHILDREN_COUNT = "children_count"; // }
import com.xda.one.api.model.interfaces.Forum; import com.xda.one.api.model.response.ResponseForum; import android.app.SearchManager; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.database.sqlite.SQLiteQueryBuilder; import android.provider.BaseColumns; import android.text.TextUtils; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import static com.xda.one.db.ForumDbHelper.ForumContract.ForumEntry;
package com.xda.one.db; public class ForumDbHelper extends SQLiteOpenHelper { public static final int DATABASE_VERSION = 3; public static final String DATABASE_NAME = "Forums.db"; public static final String TABLE_NAME = "forumtable"; private static final String SQL_DELETE_ENTRIES = "DROP TABLE IF EXISTS " + TABLE_NAME; private static final String TEXT_TYPE = " TEXT"; private static final String INTEGER_TYPE = " INTEGER"; private static final String COMMA_SEP = ","; private static final String UNIQUE = " UNIQUE"; private static final String SQL_CREATE_FORUM_TABLE = "CREATE TABLE " + TABLE_NAME + " (" +
// Path: android/src/main/java/com/xda/one/api/model/interfaces/Forum.java // public interface Forum extends Parcelable { // // public String getTitle(); // // public int getForumId(); // // public int getParentId(); // // public String getForumSlug(); // // public boolean isSubscribed(); // // public void setSubscribed(boolean subs); // // public String getImageUrl(); // // public boolean hasChildren(); // // public String getWebUri(); // // public boolean canContainThreads(); // } // // Path: android/src/main/java/com/xda/one/db/ForumDbHelper.java // public static abstract class ForumEntry implements BaseColumns { // // public static final String COLUMN_NAME_TITLE = "title"; // // public static final String COLUMN_NAME_CONTENT = "content"; // // public static final String COLUMN_NAME_FORUMID = "forumid"; // // public static final String COLUMN_NAME_PARENTID = "parentid"; // // public static final String COLUMN_NAME_FORUMSLUG = "forumslug"; // // public static final String COLUMN_NAME_SUBSCRIBED = "subscribed"; // // public static final String COLUMN_NAME_IMAGE = "image"; // // public static final String COLUMN_NAME_SEARCHABLE = "searchable"; // // public static final String COLUMN_NAME_CAN_CONTAIN_THREADS = "can_contain_threads"; // // public static final String COLUMN_NAME_WEB_URI = "web_uri"; // // public static final String COLUMN_NAME_CHILDREN_COUNT = "children_count"; // } // Path: android/src/main/java/com/xda/one/db/ForumDbHelper.java import com.xda.one.api.model.interfaces.Forum; import com.xda.one.api.model.response.ResponseForum; import android.app.SearchManager; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.database.sqlite.SQLiteQueryBuilder; import android.provider.BaseColumns; import android.text.TextUtils; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import static com.xda.one.db.ForumDbHelper.ForumContract.ForumEntry; package com.xda.one.db; public class ForumDbHelper extends SQLiteOpenHelper { public static final int DATABASE_VERSION = 3; public static final String DATABASE_NAME = "Forums.db"; public static final String TABLE_NAME = "forumtable"; private static final String SQL_DELETE_ENTRIES = "DROP TABLE IF EXISTS " + TABLE_NAME; private static final String TEXT_TYPE = " TEXT"; private static final String INTEGER_TYPE = " INTEGER"; private static final String COMMA_SEP = ","; private static final String UNIQUE = " UNIQUE"; private static final String SQL_CREATE_FORUM_TABLE = "CREATE TABLE " + TABLE_NAME + " (" +
ForumEntry._ID + INTEGER_TYPE + " PRIMARY KEY" + COMMA_SEP +
xda/XDA-One
android/src/main/java/com/xda/one/db/ForumDbHelper.java
// Path: android/src/main/java/com/xda/one/api/model/interfaces/Forum.java // public interface Forum extends Parcelable { // // public String getTitle(); // // public int getForumId(); // // public int getParentId(); // // public String getForumSlug(); // // public boolean isSubscribed(); // // public void setSubscribed(boolean subs); // // public String getImageUrl(); // // public boolean hasChildren(); // // public String getWebUri(); // // public boolean canContainThreads(); // } // // Path: android/src/main/java/com/xda/one/db/ForumDbHelper.java // public static abstract class ForumEntry implements BaseColumns { // // public static final String COLUMN_NAME_TITLE = "title"; // // public static final String COLUMN_NAME_CONTENT = "content"; // // public static final String COLUMN_NAME_FORUMID = "forumid"; // // public static final String COLUMN_NAME_PARENTID = "parentid"; // // public static final String COLUMN_NAME_FORUMSLUG = "forumslug"; // // public static final String COLUMN_NAME_SUBSCRIBED = "subscribed"; // // public static final String COLUMN_NAME_IMAGE = "image"; // // public static final String COLUMN_NAME_SEARCHABLE = "searchable"; // // public static final String COLUMN_NAME_CAN_CONTAIN_THREADS = "can_contain_threads"; // // public static final String COLUMN_NAME_WEB_URI = "web_uri"; // // public static final String COLUMN_NAME_CHILDREN_COUNT = "children_count"; // }
import com.xda.one.api.model.interfaces.Forum; import com.xda.one.api.model.response.ResponseForum; import android.app.SearchManager; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.database.sqlite.SQLiteQueryBuilder; import android.provider.BaseColumns; import android.text.TextUtils; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import static com.xda.one.db.ForumDbHelper.ForumContract.ForumEntry;
database.endTransaction(); } } public void replaceRawForumResponse(final List<ResponseForum> list) { final SQLiteDatabase database = getWritableDatabase(); database.delete(TABLE_NAME, null, null); addAllRecursive(list); } public List<ResponseForum> getTopLevelForums() { return getForumChildren(-1); } public List<ResponseForum> getForumChildren(final int forumId) { final SQLiteDatabase database = getWritableDatabase(); final List<ResponseForum> forums = new ArrayList<>(); final Cursor cursor = getForumsChildren(database, forumId); if (cursor.getCount() > 0) { cursor.moveToFirst(); while (!cursor.isAfterLast()) { final ResponseForum forum = getForumFromCursor(cursor); forums.add(forum); cursor.moveToNext(); } } cursor.close(); return forums; }
// Path: android/src/main/java/com/xda/one/api/model/interfaces/Forum.java // public interface Forum extends Parcelable { // // public String getTitle(); // // public int getForumId(); // // public int getParentId(); // // public String getForumSlug(); // // public boolean isSubscribed(); // // public void setSubscribed(boolean subs); // // public String getImageUrl(); // // public boolean hasChildren(); // // public String getWebUri(); // // public boolean canContainThreads(); // } // // Path: android/src/main/java/com/xda/one/db/ForumDbHelper.java // public static abstract class ForumEntry implements BaseColumns { // // public static final String COLUMN_NAME_TITLE = "title"; // // public static final String COLUMN_NAME_CONTENT = "content"; // // public static final String COLUMN_NAME_FORUMID = "forumid"; // // public static final String COLUMN_NAME_PARENTID = "parentid"; // // public static final String COLUMN_NAME_FORUMSLUG = "forumslug"; // // public static final String COLUMN_NAME_SUBSCRIBED = "subscribed"; // // public static final String COLUMN_NAME_IMAGE = "image"; // // public static final String COLUMN_NAME_SEARCHABLE = "searchable"; // // public static final String COLUMN_NAME_CAN_CONTAIN_THREADS = "can_contain_threads"; // // public static final String COLUMN_NAME_WEB_URI = "web_uri"; // // public static final String COLUMN_NAME_CHILDREN_COUNT = "children_count"; // } // Path: android/src/main/java/com/xda/one/db/ForumDbHelper.java import com.xda.one.api.model.interfaces.Forum; import com.xda.one.api.model.response.ResponseForum; import android.app.SearchManager; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.database.sqlite.SQLiteQueryBuilder; import android.provider.BaseColumns; import android.text.TextUtils; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import static com.xda.one.db.ForumDbHelper.ForumContract.ForumEntry; database.endTransaction(); } } public void replaceRawForumResponse(final List<ResponseForum> list) { final SQLiteDatabase database = getWritableDatabase(); database.delete(TABLE_NAME, null, null); addAllRecursive(list); } public List<ResponseForum> getTopLevelForums() { return getForumChildren(-1); } public List<ResponseForum> getForumChildren(final int forumId) { final SQLiteDatabase database = getWritableDatabase(); final List<ResponseForum> forums = new ArrayList<>(); final Cursor cursor = getForumsChildren(database, forumId); if (cursor.getCount() > 0) { cursor.moveToFirst(); while (!cursor.isAfterLast()) { final ResponseForum forum = getForumFromCursor(cursor); forums.add(forum); cursor.moveToNext(); } } cursor.close(); return forums; }
public void updateSubscribedFlag(final Forum forum, final boolean newSubscribedValue) {
xda/XDA-One
android/src/main/java/com/xda/one/model/augmented/container/AugmentedQuoteContainer.java
// Path: android/src/main/java/com/xda/one/api/model/interfaces/Quote.java // public interface Quote extends Parcelable { // // public String getPageText(); // // public int getDateLine(); // // public String getPostId(); // // public String getType(); // // String getUserId(); // // public String getUserName(); // // public String getQuotedUserId(); // // public String getQuotedUserName(); // // public int getQuotedUserGroupId(); // // public int getQuotedInfractionGroupId(); // // public UnifiedThread getThread(); // // public String getAvatarUrl(); // } // // Path: android/src/main/java/com/xda/one/model/augmented/AugmentedQuote.java // public final class AugmentedQuote implements Quote { // // public static final Creator<AugmentedQuote> CREATOR = new Creator<AugmentedQuote>() { // @Override // public AugmentedQuote createFromParcel(Parcel source) { // return new AugmentedQuote(source); // } // // @Override // public AugmentedQuote[] newArray(int size) { // return new AugmentedQuote[size]; // } // }; // // private static final String QUOTE_USERNAME_CONTENT_SEPARATOR = " - "; // // private final Quote mQuote; // // private final AugmentedUnifiedThread mUnifiedThread; // // private final Spanned mCombinedUsernameContent; // // public AugmentedQuote(final Quote quote, final Context context, final int primary, // final int secondary) { // mQuote = quote; // mUnifiedThread = new AugmentedUnifiedThread(quote.getThread(), context); // // final Spanned parsed = ContentParser.parseBBCode(context, quote.getPageText()); // final SpannableStringBuilder builder = new SpannableStringBuilder(quote // .getUserName()); // // final int primaryEnd = builder.length(); // builder.setSpan(new ForegroundColorSpan(primary), 0, primaryEnd, // Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); // // builder.append(QUOTE_USERNAME_CONTENT_SEPARATOR); // builder.append(parsed); // builder.setSpan(new ForegroundColorSpan(secondary), primaryEnd, builder.length(), // Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); // // mCombinedUsernameContent = builder; // } // // private AugmentedQuote(final Parcel source) { // mQuote = new ResponseQuote(source); // // mCombinedUsernameContent = Html.fromHtml(source.readString()); // mUnifiedThread = new AugmentedUnifiedThread(source); // } // // public Spanned getCombinedUsernameContent() { // return mCombinedUsernameContent; // } // // @Override // public String getPageText() { // return mQuote.getPageText(); // } // // @Override // public int getDateLine() { // return mQuote.getDateLine(); // } // // @Override // public String getPostId() { // return mQuote.getPostId(); // } // // @Override // public String getType() { // return mQuote.getType(); // } // // @Override // public String getUserId() { // return mQuote.getUserId(); // } // // @Override // public String getUserName() { // return mQuote.getUserName(); // } // // @Override // public String getQuotedUserId() { // return mQuote.getQuotedUserId(); // } // // @Override // public String getQuotedUserName() { // return mQuote.getQuotedUserName(); // } // // @Override // public int getQuotedUserGroupId() { // return mQuote.getQuotedUserGroupId(); // } // // @Override // public int getQuotedInfractionGroupId() { // return mQuote.getQuotedInfractionGroupId(); // } // // @Override // public AugmentedUnifiedThread getThread() { // return mUnifiedThread; // } // // @Override // public String getAvatarUrl() { // return mQuote.getAvatarUrl(); // } // // @Override // public int describeContents() { // return mQuote.describeContents(); // } // // @Override // public void writeToParcel(final Parcel dest, final int flags) { // mQuote.writeToParcel(dest, flags); // // dest.writeString(Html.toHtml(mCombinedUsernameContent)); // dest.writeParcelable(mUnifiedThread, flags); // } // }
import com.xda.one.R; import com.xda.one.api.model.interfaces.Quote; import com.xda.one.api.model.interfaces.container.QuoteContainer; import com.xda.one.model.augmented.AugmentedQuote; import android.content.Context; import java.util.ArrayList; import java.util.List;
package com.xda.one.model.augmented.container; public class AugmentedQuoteContainer implements QuoteContainer { private final QuoteContainer mQuoteContainer;
// Path: android/src/main/java/com/xda/one/api/model/interfaces/Quote.java // public interface Quote extends Parcelable { // // public String getPageText(); // // public int getDateLine(); // // public String getPostId(); // // public String getType(); // // String getUserId(); // // public String getUserName(); // // public String getQuotedUserId(); // // public String getQuotedUserName(); // // public int getQuotedUserGroupId(); // // public int getQuotedInfractionGroupId(); // // public UnifiedThread getThread(); // // public String getAvatarUrl(); // } // // Path: android/src/main/java/com/xda/one/model/augmented/AugmentedQuote.java // public final class AugmentedQuote implements Quote { // // public static final Creator<AugmentedQuote> CREATOR = new Creator<AugmentedQuote>() { // @Override // public AugmentedQuote createFromParcel(Parcel source) { // return new AugmentedQuote(source); // } // // @Override // public AugmentedQuote[] newArray(int size) { // return new AugmentedQuote[size]; // } // }; // // private static final String QUOTE_USERNAME_CONTENT_SEPARATOR = " - "; // // private final Quote mQuote; // // private final AugmentedUnifiedThread mUnifiedThread; // // private final Spanned mCombinedUsernameContent; // // public AugmentedQuote(final Quote quote, final Context context, final int primary, // final int secondary) { // mQuote = quote; // mUnifiedThread = new AugmentedUnifiedThread(quote.getThread(), context); // // final Spanned parsed = ContentParser.parseBBCode(context, quote.getPageText()); // final SpannableStringBuilder builder = new SpannableStringBuilder(quote // .getUserName()); // // final int primaryEnd = builder.length(); // builder.setSpan(new ForegroundColorSpan(primary), 0, primaryEnd, // Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); // // builder.append(QUOTE_USERNAME_CONTENT_SEPARATOR); // builder.append(parsed); // builder.setSpan(new ForegroundColorSpan(secondary), primaryEnd, builder.length(), // Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); // // mCombinedUsernameContent = builder; // } // // private AugmentedQuote(final Parcel source) { // mQuote = new ResponseQuote(source); // // mCombinedUsernameContent = Html.fromHtml(source.readString()); // mUnifiedThread = new AugmentedUnifiedThread(source); // } // // public Spanned getCombinedUsernameContent() { // return mCombinedUsernameContent; // } // // @Override // public String getPageText() { // return mQuote.getPageText(); // } // // @Override // public int getDateLine() { // return mQuote.getDateLine(); // } // // @Override // public String getPostId() { // return mQuote.getPostId(); // } // // @Override // public String getType() { // return mQuote.getType(); // } // // @Override // public String getUserId() { // return mQuote.getUserId(); // } // // @Override // public String getUserName() { // return mQuote.getUserName(); // } // // @Override // public String getQuotedUserId() { // return mQuote.getQuotedUserId(); // } // // @Override // public String getQuotedUserName() { // return mQuote.getQuotedUserName(); // } // // @Override // public int getQuotedUserGroupId() { // return mQuote.getQuotedUserGroupId(); // } // // @Override // public int getQuotedInfractionGroupId() { // return mQuote.getQuotedInfractionGroupId(); // } // // @Override // public AugmentedUnifiedThread getThread() { // return mUnifiedThread; // } // // @Override // public String getAvatarUrl() { // return mQuote.getAvatarUrl(); // } // // @Override // public int describeContents() { // return mQuote.describeContents(); // } // // @Override // public void writeToParcel(final Parcel dest, final int flags) { // mQuote.writeToParcel(dest, flags); // // dest.writeString(Html.toHtml(mCombinedUsernameContent)); // dest.writeParcelable(mUnifiedThread, flags); // } // } // Path: android/src/main/java/com/xda/one/model/augmented/container/AugmentedQuoteContainer.java import com.xda.one.R; import com.xda.one.api.model.interfaces.Quote; import com.xda.one.api.model.interfaces.container.QuoteContainer; import com.xda.one.model.augmented.AugmentedQuote; import android.content.Context; import java.util.ArrayList; import java.util.List; package com.xda.one.model.augmented.container; public class AugmentedQuoteContainer implements QuoteContainer { private final QuoteContainer mQuoteContainer;
private final ArrayList<AugmentedQuote> mQuotes;
xda/XDA-One
android/src/main/java/com/xda/one/model/augmented/container/AugmentedQuoteContainer.java
// Path: android/src/main/java/com/xda/one/api/model/interfaces/Quote.java // public interface Quote extends Parcelable { // // public String getPageText(); // // public int getDateLine(); // // public String getPostId(); // // public String getType(); // // String getUserId(); // // public String getUserName(); // // public String getQuotedUserId(); // // public String getQuotedUserName(); // // public int getQuotedUserGroupId(); // // public int getQuotedInfractionGroupId(); // // public UnifiedThread getThread(); // // public String getAvatarUrl(); // } // // Path: android/src/main/java/com/xda/one/model/augmented/AugmentedQuote.java // public final class AugmentedQuote implements Quote { // // public static final Creator<AugmentedQuote> CREATOR = new Creator<AugmentedQuote>() { // @Override // public AugmentedQuote createFromParcel(Parcel source) { // return new AugmentedQuote(source); // } // // @Override // public AugmentedQuote[] newArray(int size) { // return new AugmentedQuote[size]; // } // }; // // private static final String QUOTE_USERNAME_CONTENT_SEPARATOR = " - "; // // private final Quote mQuote; // // private final AugmentedUnifiedThread mUnifiedThread; // // private final Spanned mCombinedUsernameContent; // // public AugmentedQuote(final Quote quote, final Context context, final int primary, // final int secondary) { // mQuote = quote; // mUnifiedThread = new AugmentedUnifiedThread(quote.getThread(), context); // // final Spanned parsed = ContentParser.parseBBCode(context, quote.getPageText()); // final SpannableStringBuilder builder = new SpannableStringBuilder(quote // .getUserName()); // // final int primaryEnd = builder.length(); // builder.setSpan(new ForegroundColorSpan(primary), 0, primaryEnd, // Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); // // builder.append(QUOTE_USERNAME_CONTENT_SEPARATOR); // builder.append(parsed); // builder.setSpan(new ForegroundColorSpan(secondary), primaryEnd, builder.length(), // Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); // // mCombinedUsernameContent = builder; // } // // private AugmentedQuote(final Parcel source) { // mQuote = new ResponseQuote(source); // // mCombinedUsernameContent = Html.fromHtml(source.readString()); // mUnifiedThread = new AugmentedUnifiedThread(source); // } // // public Spanned getCombinedUsernameContent() { // return mCombinedUsernameContent; // } // // @Override // public String getPageText() { // return mQuote.getPageText(); // } // // @Override // public int getDateLine() { // return mQuote.getDateLine(); // } // // @Override // public String getPostId() { // return mQuote.getPostId(); // } // // @Override // public String getType() { // return mQuote.getType(); // } // // @Override // public String getUserId() { // return mQuote.getUserId(); // } // // @Override // public String getUserName() { // return mQuote.getUserName(); // } // // @Override // public String getQuotedUserId() { // return mQuote.getQuotedUserId(); // } // // @Override // public String getQuotedUserName() { // return mQuote.getQuotedUserName(); // } // // @Override // public int getQuotedUserGroupId() { // return mQuote.getQuotedUserGroupId(); // } // // @Override // public int getQuotedInfractionGroupId() { // return mQuote.getQuotedInfractionGroupId(); // } // // @Override // public AugmentedUnifiedThread getThread() { // return mUnifiedThread; // } // // @Override // public String getAvatarUrl() { // return mQuote.getAvatarUrl(); // } // // @Override // public int describeContents() { // return mQuote.describeContents(); // } // // @Override // public void writeToParcel(final Parcel dest, final int flags) { // mQuote.writeToParcel(dest, flags); // // dest.writeString(Html.toHtml(mCombinedUsernameContent)); // dest.writeParcelable(mUnifiedThread, flags); // } // }
import com.xda.one.R; import com.xda.one.api.model.interfaces.Quote; import com.xda.one.api.model.interfaces.container.QuoteContainer; import com.xda.one.model.augmented.AugmentedQuote; import android.content.Context; import java.util.ArrayList; import java.util.List;
package com.xda.one.model.augmented.container; public class AugmentedQuoteContainer implements QuoteContainer { private final QuoteContainer mQuoteContainer; private final ArrayList<AugmentedQuote> mQuotes; public AugmentedQuoteContainer(final QuoteContainer quoteContainer, final Context context) { mQuoteContainer = quoteContainer; mQuotes = new ArrayList<>(); final int primary = context.getResources().getColor(R.color.default_primary_text); final int secondary = context.getResources().getColor(R.color.default_secondary_text);
// Path: android/src/main/java/com/xda/one/api/model/interfaces/Quote.java // public interface Quote extends Parcelable { // // public String getPageText(); // // public int getDateLine(); // // public String getPostId(); // // public String getType(); // // String getUserId(); // // public String getUserName(); // // public String getQuotedUserId(); // // public String getQuotedUserName(); // // public int getQuotedUserGroupId(); // // public int getQuotedInfractionGroupId(); // // public UnifiedThread getThread(); // // public String getAvatarUrl(); // } // // Path: android/src/main/java/com/xda/one/model/augmented/AugmentedQuote.java // public final class AugmentedQuote implements Quote { // // public static final Creator<AugmentedQuote> CREATOR = new Creator<AugmentedQuote>() { // @Override // public AugmentedQuote createFromParcel(Parcel source) { // return new AugmentedQuote(source); // } // // @Override // public AugmentedQuote[] newArray(int size) { // return new AugmentedQuote[size]; // } // }; // // private static final String QUOTE_USERNAME_CONTENT_SEPARATOR = " - "; // // private final Quote mQuote; // // private final AugmentedUnifiedThread mUnifiedThread; // // private final Spanned mCombinedUsernameContent; // // public AugmentedQuote(final Quote quote, final Context context, final int primary, // final int secondary) { // mQuote = quote; // mUnifiedThread = new AugmentedUnifiedThread(quote.getThread(), context); // // final Spanned parsed = ContentParser.parseBBCode(context, quote.getPageText()); // final SpannableStringBuilder builder = new SpannableStringBuilder(quote // .getUserName()); // // final int primaryEnd = builder.length(); // builder.setSpan(new ForegroundColorSpan(primary), 0, primaryEnd, // Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); // // builder.append(QUOTE_USERNAME_CONTENT_SEPARATOR); // builder.append(parsed); // builder.setSpan(new ForegroundColorSpan(secondary), primaryEnd, builder.length(), // Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); // // mCombinedUsernameContent = builder; // } // // private AugmentedQuote(final Parcel source) { // mQuote = new ResponseQuote(source); // // mCombinedUsernameContent = Html.fromHtml(source.readString()); // mUnifiedThread = new AugmentedUnifiedThread(source); // } // // public Spanned getCombinedUsernameContent() { // return mCombinedUsernameContent; // } // // @Override // public String getPageText() { // return mQuote.getPageText(); // } // // @Override // public int getDateLine() { // return mQuote.getDateLine(); // } // // @Override // public String getPostId() { // return mQuote.getPostId(); // } // // @Override // public String getType() { // return mQuote.getType(); // } // // @Override // public String getUserId() { // return mQuote.getUserId(); // } // // @Override // public String getUserName() { // return mQuote.getUserName(); // } // // @Override // public String getQuotedUserId() { // return mQuote.getQuotedUserId(); // } // // @Override // public String getQuotedUserName() { // return mQuote.getQuotedUserName(); // } // // @Override // public int getQuotedUserGroupId() { // return mQuote.getQuotedUserGroupId(); // } // // @Override // public int getQuotedInfractionGroupId() { // return mQuote.getQuotedInfractionGroupId(); // } // // @Override // public AugmentedUnifiedThread getThread() { // return mUnifiedThread; // } // // @Override // public String getAvatarUrl() { // return mQuote.getAvatarUrl(); // } // // @Override // public int describeContents() { // return mQuote.describeContents(); // } // // @Override // public void writeToParcel(final Parcel dest, final int flags) { // mQuote.writeToParcel(dest, flags); // // dest.writeString(Html.toHtml(mCombinedUsernameContent)); // dest.writeParcelable(mUnifiedThread, flags); // } // } // Path: android/src/main/java/com/xda/one/model/augmented/container/AugmentedQuoteContainer.java import com.xda.one.R; import com.xda.one.api.model.interfaces.Quote; import com.xda.one.api.model.interfaces.container.QuoteContainer; import com.xda.one.model.augmented.AugmentedQuote; import android.content.Context; import java.util.ArrayList; import java.util.List; package com.xda.one.model.augmented.container; public class AugmentedQuoteContainer implements QuoteContainer { private final QuoteContainer mQuoteContainer; private final ArrayList<AugmentedQuote> mQuotes; public AugmentedQuoteContainer(final QuoteContainer quoteContainer, final Context context) { mQuoteContainer = quoteContainer; mQuotes = new ArrayList<>(); final int primary = context.getResources().getColor(R.color.default_primary_text); final int secondary = context.getResources().getColor(R.color.default_secondary_text);
for (final Quote quote : quoteContainer.getQuotes()) {
xda/XDA-One
android/src/main/java/com/xda/one/api/inteface/NewsClient.java
// Path: android/src/main/java/com/xda/one/api/model/response/container/ResponseNewsContainer.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class ResponseNewsContainer implements Parcelable { // // public static final Creator<ResponseNewsContainer> CREATOR // = new Creator<ResponseNewsContainer>() { // @Override // public ResponseNewsContainer createFromParcel(Parcel source) { // return new ResponseNewsContainer(source); // } // // @Override // public ResponseNewsContainer[] newArray(int size) { // return new ResponseNewsContainer[size]; // } // }; // // @JsonProperty(value = "posts") // private List<ResponseNews> mPosts; // // @JsonProperty(value = "pages") // private int mTotalPages; // // private int mCurrentPage; // // public ResponseNewsContainer() { // } // // private ResponseNewsContainer(Parcel in) { // mPosts = new ArrayList<>(); // in.readTypedList(mPosts, ResponseNews.CREATOR); // mTotalPages = in.readInt(); // mCurrentPage = in.readInt(); // } // // public List<ResponseNews> getNewsItems() { // return mPosts; // } // // public int getTotalPages() { // return mTotalPages; // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeTypedList(mPosts); // dest.writeInt(mTotalPages); // dest.writeInt(mCurrentPage); // } // // public int getCurrentPage() { // return mCurrentPage; // } // // public void setCurrentPage(final int currentPage) { // mCurrentPage = currentPage; // } // }
import com.xda.one.api.misc.EventBus; import com.xda.one.api.model.response.container.ResponseNewsContainer; import com.xda.one.api.model.response.container.ResponsePostContainer; import retrofit.Callback;
package com.xda.one.api.inteface; public interface NewsClient { public EventBus getBus();
// Path: android/src/main/java/com/xda/one/api/model/response/container/ResponseNewsContainer.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class ResponseNewsContainer implements Parcelable { // // public static final Creator<ResponseNewsContainer> CREATOR // = new Creator<ResponseNewsContainer>() { // @Override // public ResponseNewsContainer createFromParcel(Parcel source) { // return new ResponseNewsContainer(source); // } // // @Override // public ResponseNewsContainer[] newArray(int size) { // return new ResponseNewsContainer[size]; // } // }; // // @JsonProperty(value = "posts") // private List<ResponseNews> mPosts; // // @JsonProperty(value = "pages") // private int mTotalPages; // // private int mCurrentPage; // // public ResponseNewsContainer() { // } // // private ResponseNewsContainer(Parcel in) { // mPosts = new ArrayList<>(); // in.readTypedList(mPosts, ResponseNews.CREATOR); // mTotalPages = in.readInt(); // mCurrentPage = in.readInt(); // } // // public List<ResponseNews> getNewsItems() { // return mPosts; // } // // public int getTotalPages() { // return mTotalPages; // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeTypedList(mPosts); // dest.writeInt(mTotalPages); // dest.writeInt(mCurrentPage); // } // // public int getCurrentPage() { // return mCurrentPage; // } // // public void setCurrentPage(final int currentPage) { // mCurrentPage = currentPage; // } // } // Path: android/src/main/java/com/xda/one/api/inteface/NewsClient.java import com.xda.one.api.misc.EventBus; import com.xda.one.api.model.response.container.ResponseNewsContainer; import com.xda.one.api.model.response.container.ResponsePostContainer; import retrofit.Callback; package com.xda.one.api.inteface; public interface NewsClient { public EventBus getBus();
public ResponseNewsContainer getNews(final int page);
xda/XDA-One
android/src/main/java/com/xda/one/ui/ForumAdapter.java
// Path: android/src/main/java/com/xda/one/api/model/interfaces/Forum.java // public interface Forum extends Parcelable { // // public String getTitle(); // // public int getForumId(); // // public int getParentId(); // // public String getForumSlug(); // // public boolean isSubscribed(); // // public void setSubscribed(boolean subs); // // public String getImageUrl(); // // public boolean hasChildren(); // // public String getWebUri(); // // public boolean canContainThreads(); // } // // Path: android/src/main/java/com/xda/one/util/Utils.java // public class Utils { // // public static String handleRetrofitErrorQuietly(final RetrofitError error) { // error.printStackTrace(); // // InputStream inputStream = null; // try { // if (error.isNetworkError()) { // Log.e("XDA-ONE", "Network error happened."); // } else { // final TypedInput body = error.getResponse().getBody(); // if (body == null) { // Log.e("XDA-ONE", "Unable to retrieve body"); // return null; // } // inputStream = body.in(); // // final String result = IOUtils.toString(inputStream); // Log.e("XDA-ONE", result); // return result; // } // } catch (IOException e) { // e.printStackTrace(); // } finally { // IOUtils.closeQuietly(inputStream); // } // return null; // } // // public static <T> int getCollectionSize(final Collection<T> collection) { // return collection == null ? 0 : collection.size(); // } // // public static boolean isCollectionEmpty(final Collection collection) { // return collection == null || collection.isEmpty(); // } // // public static CharSequence getRelativeDate(final Context context, final long dateline) { // return DateUtils.getRelativeDateTimeString(context, dateline, // DateUtils.SECOND_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, // DateUtils.FORMAT_NUMERIC_DATE); // } // }
import com.xda.one.R; import com.xda.one.api.model.interfaces.Forum; import com.xda.one.ui.helper.ActionModeHelper; import com.xda.one.util.Utils; import android.content.Context; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import java.util.ArrayList; import java.util.List;
// The full item forumHolder.itemView.setOnClickListener(mListener); forumHolder.itemView.setOnLongClickListener(mLongClickListener); if (mModeHelper != null) { // Update the activated state of the item mModeHelper.updateActivatedState(forumHolder.itemView, position); } // Setup the device view mImageViewDeviceDelegate.setupImageViewDevice(forumHolder.deviceImageView, forum); // Title of forum forumHolder.titleTextView.setText(forum.getTitle()); // Setup the subscribe button mSubscribeButtonDelegate.setupSubscribeButton(forumHolder.subscribeButton, forum); } @Override public int getItemCount() { return mForums.size(); } public T getForum(final int position) { return mForums.get(position); } public void addAll(final List<? extends T> forums) {
// Path: android/src/main/java/com/xda/one/api/model/interfaces/Forum.java // public interface Forum extends Parcelable { // // public String getTitle(); // // public int getForumId(); // // public int getParentId(); // // public String getForumSlug(); // // public boolean isSubscribed(); // // public void setSubscribed(boolean subs); // // public String getImageUrl(); // // public boolean hasChildren(); // // public String getWebUri(); // // public boolean canContainThreads(); // } // // Path: android/src/main/java/com/xda/one/util/Utils.java // public class Utils { // // public static String handleRetrofitErrorQuietly(final RetrofitError error) { // error.printStackTrace(); // // InputStream inputStream = null; // try { // if (error.isNetworkError()) { // Log.e("XDA-ONE", "Network error happened."); // } else { // final TypedInput body = error.getResponse().getBody(); // if (body == null) { // Log.e("XDA-ONE", "Unable to retrieve body"); // return null; // } // inputStream = body.in(); // // final String result = IOUtils.toString(inputStream); // Log.e("XDA-ONE", result); // return result; // } // } catch (IOException e) { // e.printStackTrace(); // } finally { // IOUtils.closeQuietly(inputStream); // } // return null; // } // // public static <T> int getCollectionSize(final Collection<T> collection) { // return collection == null ? 0 : collection.size(); // } // // public static boolean isCollectionEmpty(final Collection collection) { // return collection == null || collection.isEmpty(); // } // // public static CharSequence getRelativeDate(final Context context, final long dateline) { // return DateUtils.getRelativeDateTimeString(context, dateline, // DateUtils.SECOND_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, // DateUtils.FORMAT_NUMERIC_DATE); // } // } // Path: android/src/main/java/com/xda/one/ui/ForumAdapter.java import com.xda.one.R; import com.xda.one.api.model.interfaces.Forum; import com.xda.one.ui.helper.ActionModeHelper; import com.xda.one.util.Utils; import android.content.Context; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import java.util.ArrayList; import java.util.List; // The full item forumHolder.itemView.setOnClickListener(mListener); forumHolder.itemView.setOnLongClickListener(mLongClickListener); if (mModeHelper != null) { // Update the activated state of the item mModeHelper.updateActivatedState(forumHolder.itemView, position); } // Setup the device view mImageViewDeviceDelegate.setupImageViewDevice(forumHolder.deviceImageView, forum); // Title of forum forumHolder.titleTextView.setText(forum.getTitle()); // Setup the subscribe button mSubscribeButtonDelegate.setupSubscribeButton(forumHolder.subscribeButton, forum); } @Override public int getItemCount() { return mForums.size(); } public T getForum(final int position) { return mForums.get(position); } public void addAll(final List<? extends T> forums) {
if (Utils.isCollectionEmpty(forums)) {
xda/XDA-One
android/src/main/java/com/xda/one/api/model/interfaces/Post.java
// Path: android/src/main/java/com/xda/one/api/model/response/ResponseAttachment.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class ResponseAttachment implements Parcelable { // // public static final Parcelable.Creator<ResponseAttachment> CREATOR // = new Parcelable.Creator<ResponseAttachment>() { // @Override // public ResponseAttachment createFromParcel(Parcel source) { // return new ResponseAttachment(source); // } // // @Override // public ResponseAttachment[] newArray(int size) { // return new ResponseAttachment[size]; // } // }; // // @JsonProperty(value = "dateline") // private long mDateLine; // // @JsonProperty(value = "thumbnail_dateline") // private long mThumbnailDateLine; // // @JsonProperty(value = "filename") // private String mFileName; // // @JsonProperty(value = "filesize") // private float mFileSize; // // @JsonProperty(value = "visible") // private int mVisible; // // @JsonProperty(value = "attachmentid") // private int mAttachmentId; // // @JsonProperty(value = "counter") // private int mCounter; // // @JsonProperty(value = "postid") // private int mPostId; // // @JsonProperty(value = "hasthumbnail") // private int mHasThumbnail; // // @JsonProperty(value = "thumbnail_filesize") // private int mThumbnailFileSize; // // @JsonProperty(value = "build_thumbnail") // private int mBuildThumbnail; // // @JsonProperty(value = "newwindow") // private int mNewWindow; // // @JsonProperty(value = "attachment_url") // private String mAttachmentUrl; // // public ResponseAttachment() { // } // // private ResponseAttachment(final Parcel in) { // mDateLine = in.readLong(); // mThumbnailDateLine = in.readLong(); // mFileName = in.readString(); // mFileSize = in.readFloat(); // mVisible = in.readInt(); // mAttachmentId = in.readInt(); // mCounter = in.readInt(); // mPostId = in.readInt(); // mHasThumbnail = in.readInt(); // mThumbnailFileSize = in.readInt(); // mBuildThumbnail = in.readInt(); // mNewWindow = in.readInt(); // mAttachmentUrl = in.readString(); // } // // public long getDateLine() { // return mDateLine; // } // // public long getThumbnailDateLine() { // return mThumbnailDateLine; // } // // public String getFileName() { // return mFileName; // } // // public float getFileSize() { // return mFileSize; // } // // public boolean isVisible() { // return mVisible != 0; // } // // public int getAttachmentId() { // return mAttachmentId; // } // // public int getCounter() { // return mCounter; // } // // public int getPostId() { // return mPostId; // } // // public boolean hasThumbnail() { // return mHasThumbnail != 0; // } // // public int getThumbnailFileSize() { // return mThumbnailFileSize; // } // // public int getBuildThumbnail() { // return mBuildThumbnail; // } // // public boolean isNewWindow() { // return mNewWindow != 0; // } // // public String getAttachmentUrl() { // return mAttachmentUrl; // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeLong(mDateLine); // dest.writeLong(mThumbnailDateLine); // dest.writeString(mFileName); // dest.writeFloat(mFileSize); // dest.writeInt(mVisible); // dest.writeInt(mAttachmentId); // dest.writeInt(mCounter); // dest.writeInt(mPostId); // dest.writeInt(mHasThumbnail); // dest.writeInt(mThumbnailFileSize); // dest.writeInt(mBuildThumbnail); // dest.writeInt(mNewWindow); // dest.writeString(mAttachmentUrl); // } // }
import com.xda.one.api.model.response.ResponseAttachment; import android.os.Parcelable; import java.util.List;
package com.xda.one.api.model.interfaces; public interface Post extends Parcelable { public int getPostId(); public int getVisible(); public String getUserId(); public String getTitle(); public String getPageText(); public String getUserName(); public long getDateline();
// Path: android/src/main/java/com/xda/one/api/model/response/ResponseAttachment.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class ResponseAttachment implements Parcelable { // // public static final Parcelable.Creator<ResponseAttachment> CREATOR // = new Parcelable.Creator<ResponseAttachment>() { // @Override // public ResponseAttachment createFromParcel(Parcel source) { // return new ResponseAttachment(source); // } // // @Override // public ResponseAttachment[] newArray(int size) { // return new ResponseAttachment[size]; // } // }; // // @JsonProperty(value = "dateline") // private long mDateLine; // // @JsonProperty(value = "thumbnail_dateline") // private long mThumbnailDateLine; // // @JsonProperty(value = "filename") // private String mFileName; // // @JsonProperty(value = "filesize") // private float mFileSize; // // @JsonProperty(value = "visible") // private int mVisible; // // @JsonProperty(value = "attachmentid") // private int mAttachmentId; // // @JsonProperty(value = "counter") // private int mCounter; // // @JsonProperty(value = "postid") // private int mPostId; // // @JsonProperty(value = "hasthumbnail") // private int mHasThumbnail; // // @JsonProperty(value = "thumbnail_filesize") // private int mThumbnailFileSize; // // @JsonProperty(value = "build_thumbnail") // private int mBuildThumbnail; // // @JsonProperty(value = "newwindow") // private int mNewWindow; // // @JsonProperty(value = "attachment_url") // private String mAttachmentUrl; // // public ResponseAttachment() { // } // // private ResponseAttachment(final Parcel in) { // mDateLine = in.readLong(); // mThumbnailDateLine = in.readLong(); // mFileName = in.readString(); // mFileSize = in.readFloat(); // mVisible = in.readInt(); // mAttachmentId = in.readInt(); // mCounter = in.readInt(); // mPostId = in.readInt(); // mHasThumbnail = in.readInt(); // mThumbnailFileSize = in.readInt(); // mBuildThumbnail = in.readInt(); // mNewWindow = in.readInt(); // mAttachmentUrl = in.readString(); // } // // public long getDateLine() { // return mDateLine; // } // // public long getThumbnailDateLine() { // return mThumbnailDateLine; // } // // public String getFileName() { // return mFileName; // } // // public float getFileSize() { // return mFileSize; // } // // public boolean isVisible() { // return mVisible != 0; // } // // public int getAttachmentId() { // return mAttachmentId; // } // // public int getCounter() { // return mCounter; // } // // public int getPostId() { // return mPostId; // } // // public boolean hasThumbnail() { // return mHasThumbnail != 0; // } // // public int getThumbnailFileSize() { // return mThumbnailFileSize; // } // // public int getBuildThumbnail() { // return mBuildThumbnail; // } // // public boolean isNewWindow() { // return mNewWindow != 0; // } // // public String getAttachmentUrl() { // return mAttachmentUrl; // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeLong(mDateLine); // dest.writeLong(mThumbnailDateLine); // dest.writeString(mFileName); // dest.writeFloat(mFileSize); // dest.writeInt(mVisible); // dest.writeInt(mAttachmentId); // dest.writeInt(mCounter); // dest.writeInt(mPostId); // dest.writeInt(mHasThumbnail); // dest.writeInt(mThumbnailFileSize); // dest.writeInt(mBuildThumbnail); // dest.writeInt(mNewWindow); // dest.writeString(mAttachmentUrl); // } // } // Path: android/src/main/java/com/xda/one/api/model/interfaces/Post.java import com.xda.one.api.model.response.ResponseAttachment; import android.os.Parcelable; import java.util.List; package com.xda.one.api.model.interfaces; public interface Post extends Parcelable { public int getPostId(); public int getVisible(); public String getUserId(); public String getTitle(); public String getPageText(); public String getUserName(); public long getDateline();
public List<ResponseAttachment> getAttachments();
xda/XDA-One
android/src/main/java/com/xda/one/api/model/response/ResponseQuote.java
// Path: android/src/main/java/com/xda/one/api/model/interfaces/Quote.java // public interface Quote extends Parcelable { // // public String getPageText(); // // public int getDateLine(); // // public String getPostId(); // // public String getType(); // // String getUserId(); // // public String getUserName(); // // public String getQuotedUserId(); // // public String getQuotedUserName(); // // public int getQuotedUserGroupId(); // // public int getQuotedInfractionGroupId(); // // public UnifiedThread getThread(); // // public String getAvatarUrl(); // } // // Path: android/src/main/java/com/xda/one/api/model/interfaces/UnifiedThread.java // public interface UnifiedThread extends Parcelable { // // public String getThreadId(); // // public boolean isAttach(); // // public boolean hasAttachment(); // // public int getViews(); // // public long getLastPost(); // // public String getTitle(); // // public String getFirstPostContent(); // // public String getPostUsername(); // // public boolean isSticky(); // // public int getTotalPosts(); // // public int getLastPostId(); // // public String getLastPoster(); // // public int getFirstPostId(); // // public String getThreadSlug(); // // String getForumTitle(); // // public int getForumId(); // // public int getReplyCount(); // // public boolean isSubscribed(); // // public String getAvatarUrl(); // // public boolean isUnread(); // // boolean isOpen(); // // public String getWebUri(); // }
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.xda.one.api.model.interfaces.Quote; import com.xda.one.api.model.interfaces.UnifiedThread; import android.os.Parcel;
public String getUserId() { return mUserId; } @Override public String getUserName() { return mUserName; } @Override public String getQuotedUserId() { return mQuotedUserId; } @Override public String getQuotedUserName() { return mQuotedUserName; } @Override public int getQuotedUserGroupId() { return mQuotedUserGroupId; } @Override public int getQuotedInfractionGroupId() { return mQuotedInfractionGroupId; } @Override
// Path: android/src/main/java/com/xda/one/api/model/interfaces/Quote.java // public interface Quote extends Parcelable { // // public String getPageText(); // // public int getDateLine(); // // public String getPostId(); // // public String getType(); // // String getUserId(); // // public String getUserName(); // // public String getQuotedUserId(); // // public String getQuotedUserName(); // // public int getQuotedUserGroupId(); // // public int getQuotedInfractionGroupId(); // // public UnifiedThread getThread(); // // public String getAvatarUrl(); // } // // Path: android/src/main/java/com/xda/one/api/model/interfaces/UnifiedThread.java // public interface UnifiedThread extends Parcelable { // // public String getThreadId(); // // public boolean isAttach(); // // public boolean hasAttachment(); // // public int getViews(); // // public long getLastPost(); // // public String getTitle(); // // public String getFirstPostContent(); // // public String getPostUsername(); // // public boolean isSticky(); // // public int getTotalPosts(); // // public int getLastPostId(); // // public String getLastPoster(); // // public int getFirstPostId(); // // public String getThreadSlug(); // // String getForumTitle(); // // public int getForumId(); // // public int getReplyCount(); // // public boolean isSubscribed(); // // public String getAvatarUrl(); // // public boolean isUnread(); // // boolean isOpen(); // // public String getWebUri(); // } // Path: android/src/main/java/com/xda/one/api/model/response/ResponseQuote.java import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.xda.one.api.model.interfaces.Quote; import com.xda.one.api.model.interfaces.UnifiedThread; import android.os.Parcel; public String getUserId() { return mUserId; } @Override public String getUserName() { return mUserName; } @Override public String getQuotedUserId() { return mQuotedUserId; } @Override public String getQuotedUserName() { return mQuotedUserName; } @Override public int getQuotedUserGroupId() { return mQuotedUserGroupId; } @Override public int getQuotedInfractionGroupId() { return mQuotedInfractionGroupId; } @Override
public UnifiedThread getThread() {
xda/XDA-One
android/src/main/java/com/xda/one/api/model/response/container/ResponseMentionContainer.java
// Path: android/src/main/java/com/xda/one/api/model/interfaces/Mention.java // public interface Mention extends Parcelable { // // public String getPageText(); // // public String getDateLine(); // // public String getPostId(); // // public String getType(); // // String getUserId(); // // public String getUserName(); // // public String getMentionedUserId(); // // public String getMentionedUsername(); // // public String getMentionedUserGroupId(); // // public String getMentionedInfractionGroupId(); // // public UnifiedThread getThread(); // // String getAvatarUrl(); // } // // Path: android/src/main/java/com/xda/one/api/model/response/ResponseMention.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class ResponseMention implements Mention { // // public static final Creator<ResponseMention> CREATOR = new Creator<ResponseMention>() { // @Override // public ResponseMention createFromParcel(Parcel source) { // return new ResponseMention(source); // } // // @Override // public ResponseMention[] newArray(int size) { // return new ResponseMention[size]; // } // }; // // private final ResponseAvatar mResponseAvatar; // // @JsonProperty("pagetext") // private String mPageText; // // @JsonProperty("dateline") // private String mDateLine; // // @JsonProperty("postid") // private String mPostId; // // @JsonProperty("type") // private String mType; // // @JsonProperty("userid") // private String mUserId; // // @JsonProperty("username") // private String mUserName; // // @JsonProperty("mentioneduserid") // private String mMentionedUserId; // // @JsonProperty("mentionedusername") // private String mMentionedUsername; // // @JsonProperty("mentionedusergroupid") // private String mMentionedUserGroupId; // // @JsonProperty("mentionedinfractiongroupid") // private String mMentionedInfractionGroupId; // // @JsonProperty("thread") // private ResponseUnifiedThread mThread; // // public ResponseMention() { // mResponseAvatar = new ResponseAvatar(); // } // // public ResponseMention(Parcel in) { // mResponseAvatar = new ResponseAvatar(in); // // mPageText = in.readString(); // mDateLine = in.readString(); // mPostId = in.readString(); // mType = in.readString(); // mUserId = in.readString(); // mUserName = in.readString(); // mMentionedUserId = in.readString(); // mMentionedUsername = in.readString(); // mMentionedUserGroupId = in.readString(); // mMentionedInfractionGroupId = in.readString(); // mThread = in.readParcelable(UnifiedThread.class.getClassLoader()); // } // // @Override // public String getPageText() { // return mPageText; // } // // @Override // public String getDateLine() { // return mDateLine; // } // // @Override // public String getPostId() { // return mPostId; // } // // @Override // public String getType() { // return mType; // } // // @Override // public String getUserId() { // return mUserId; // } // // @Override // public String getUserName() { // return mUserName; // } // // @Override // public String getMentionedUserId() { // return mMentionedUserId; // } // // @Override // public String getMentionedUsername() { // return mMentionedUsername; // } // // @Override // public String getMentionedUserGroupId() { // return mMentionedUserGroupId; // } // // @Override // public String getMentionedInfractionGroupId() { // return mMentionedInfractionGroupId; // } // // @Override // public UnifiedThread getThread() { // return mThread; // } // // @Override // public String getAvatarUrl() { // return mResponseAvatar.getAvatarUrl(); // } // // @JsonProperty("avatar_url") // public void setAvatarUrl(final String avatarUrl) { // mResponseAvatar.setAvatarUrl(avatarUrl); // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // mResponseAvatar.writeToParcel(dest, flags); // // dest.writeString(mPageText); // dest.writeString(mDateLine); // dest.writeString(mPostId); // dest.writeString(mType); // dest.writeString(mUserId); // dest.writeString(mUserName); // dest.writeString(mMentionedUserId); // dest.writeString(mMentionedUsername); // dest.writeString(mMentionedUserGroupId); // dest.writeString(mMentionedInfractionGroupId); // mThread.writeToParcel(dest, flags); // } // }
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.xda.one.api.model.interfaces.Mention; import com.xda.one.api.model.interfaces.container.MentionContainer; import com.xda.one.api.model.response.ResponseMention; import java.util.ArrayList; import java.util.List;
package com.xda.one.api.model.response.container; @JsonIgnoreProperties(ignoreUnknown = true) public class ResponseMentionContainer implements MentionContainer { @JsonProperty("results")
// Path: android/src/main/java/com/xda/one/api/model/interfaces/Mention.java // public interface Mention extends Parcelable { // // public String getPageText(); // // public String getDateLine(); // // public String getPostId(); // // public String getType(); // // String getUserId(); // // public String getUserName(); // // public String getMentionedUserId(); // // public String getMentionedUsername(); // // public String getMentionedUserGroupId(); // // public String getMentionedInfractionGroupId(); // // public UnifiedThread getThread(); // // String getAvatarUrl(); // } // // Path: android/src/main/java/com/xda/one/api/model/response/ResponseMention.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class ResponseMention implements Mention { // // public static final Creator<ResponseMention> CREATOR = new Creator<ResponseMention>() { // @Override // public ResponseMention createFromParcel(Parcel source) { // return new ResponseMention(source); // } // // @Override // public ResponseMention[] newArray(int size) { // return new ResponseMention[size]; // } // }; // // private final ResponseAvatar mResponseAvatar; // // @JsonProperty("pagetext") // private String mPageText; // // @JsonProperty("dateline") // private String mDateLine; // // @JsonProperty("postid") // private String mPostId; // // @JsonProperty("type") // private String mType; // // @JsonProperty("userid") // private String mUserId; // // @JsonProperty("username") // private String mUserName; // // @JsonProperty("mentioneduserid") // private String mMentionedUserId; // // @JsonProperty("mentionedusername") // private String mMentionedUsername; // // @JsonProperty("mentionedusergroupid") // private String mMentionedUserGroupId; // // @JsonProperty("mentionedinfractiongroupid") // private String mMentionedInfractionGroupId; // // @JsonProperty("thread") // private ResponseUnifiedThread mThread; // // public ResponseMention() { // mResponseAvatar = new ResponseAvatar(); // } // // public ResponseMention(Parcel in) { // mResponseAvatar = new ResponseAvatar(in); // // mPageText = in.readString(); // mDateLine = in.readString(); // mPostId = in.readString(); // mType = in.readString(); // mUserId = in.readString(); // mUserName = in.readString(); // mMentionedUserId = in.readString(); // mMentionedUsername = in.readString(); // mMentionedUserGroupId = in.readString(); // mMentionedInfractionGroupId = in.readString(); // mThread = in.readParcelable(UnifiedThread.class.getClassLoader()); // } // // @Override // public String getPageText() { // return mPageText; // } // // @Override // public String getDateLine() { // return mDateLine; // } // // @Override // public String getPostId() { // return mPostId; // } // // @Override // public String getType() { // return mType; // } // // @Override // public String getUserId() { // return mUserId; // } // // @Override // public String getUserName() { // return mUserName; // } // // @Override // public String getMentionedUserId() { // return mMentionedUserId; // } // // @Override // public String getMentionedUsername() { // return mMentionedUsername; // } // // @Override // public String getMentionedUserGroupId() { // return mMentionedUserGroupId; // } // // @Override // public String getMentionedInfractionGroupId() { // return mMentionedInfractionGroupId; // } // // @Override // public UnifiedThread getThread() { // return mThread; // } // // @Override // public String getAvatarUrl() { // return mResponseAvatar.getAvatarUrl(); // } // // @JsonProperty("avatar_url") // public void setAvatarUrl(final String avatarUrl) { // mResponseAvatar.setAvatarUrl(avatarUrl); // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // mResponseAvatar.writeToParcel(dest, flags); // // dest.writeString(mPageText); // dest.writeString(mDateLine); // dest.writeString(mPostId); // dest.writeString(mType); // dest.writeString(mUserId); // dest.writeString(mUserName); // dest.writeString(mMentionedUserId); // dest.writeString(mMentionedUsername); // dest.writeString(mMentionedUserGroupId); // dest.writeString(mMentionedInfractionGroupId); // mThread.writeToParcel(dest, flags); // } // } // Path: android/src/main/java/com/xda/one/api/model/response/container/ResponseMentionContainer.java import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.xda.one.api.model.interfaces.Mention; import com.xda.one.api.model.interfaces.container.MentionContainer; import com.xda.one.api.model.response.ResponseMention; import java.util.ArrayList; import java.util.List; package com.xda.one.api.model.response.container; @JsonIgnoreProperties(ignoreUnknown = true) public class ResponseMentionContainer implements MentionContainer { @JsonProperty("results")
private List<ResponseMention> mMentions = new ArrayList<>();
xda/XDA-One
android/src/main/java/com/xda/one/api/model/response/container/ResponseMentionContainer.java
// Path: android/src/main/java/com/xda/one/api/model/interfaces/Mention.java // public interface Mention extends Parcelable { // // public String getPageText(); // // public String getDateLine(); // // public String getPostId(); // // public String getType(); // // String getUserId(); // // public String getUserName(); // // public String getMentionedUserId(); // // public String getMentionedUsername(); // // public String getMentionedUserGroupId(); // // public String getMentionedInfractionGroupId(); // // public UnifiedThread getThread(); // // String getAvatarUrl(); // } // // Path: android/src/main/java/com/xda/one/api/model/response/ResponseMention.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class ResponseMention implements Mention { // // public static final Creator<ResponseMention> CREATOR = new Creator<ResponseMention>() { // @Override // public ResponseMention createFromParcel(Parcel source) { // return new ResponseMention(source); // } // // @Override // public ResponseMention[] newArray(int size) { // return new ResponseMention[size]; // } // }; // // private final ResponseAvatar mResponseAvatar; // // @JsonProperty("pagetext") // private String mPageText; // // @JsonProperty("dateline") // private String mDateLine; // // @JsonProperty("postid") // private String mPostId; // // @JsonProperty("type") // private String mType; // // @JsonProperty("userid") // private String mUserId; // // @JsonProperty("username") // private String mUserName; // // @JsonProperty("mentioneduserid") // private String mMentionedUserId; // // @JsonProperty("mentionedusername") // private String mMentionedUsername; // // @JsonProperty("mentionedusergroupid") // private String mMentionedUserGroupId; // // @JsonProperty("mentionedinfractiongroupid") // private String mMentionedInfractionGroupId; // // @JsonProperty("thread") // private ResponseUnifiedThread mThread; // // public ResponseMention() { // mResponseAvatar = new ResponseAvatar(); // } // // public ResponseMention(Parcel in) { // mResponseAvatar = new ResponseAvatar(in); // // mPageText = in.readString(); // mDateLine = in.readString(); // mPostId = in.readString(); // mType = in.readString(); // mUserId = in.readString(); // mUserName = in.readString(); // mMentionedUserId = in.readString(); // mMentionedUsername = in.readString(); // mMentionedUserGroupId = in.readString(); // mMentionedInfractionGroupId = in.readString(); // mThread = in.readParcelable(UnifiedThread.class.getClassLoader()); // } // // @Override // public String getPageText() { // return mPageText; // } // // @Override // public String getDateLine() { // return mDateLine; // } // // @Override // public String getPostId() { // return mPostId; // } // // @Override // public String getType() { // return mType; // } // // @Override // public String getUserId() { // return mUserId; // } // // @Override // public String getUserName() { // return mUserName; // } // // @Override // public String getMentionedUserId() { // return mMentionedUserId; // } // // @Override // public String getMentionedUsername() { // return mMentionedUsername; // } // // @Override // public String getMentionedUserGroupId() { // return mMentionedUserGroupId; // } // // @Override // public String getMentionedInfractionGroupId() { // return mMentionedInfractionGroupId; // } // // @Override // public UnifiedThread getThread() { // return mThread; // } // // @Override // public String getAvatarUrl() { // return mResponseAvatar.getAvatarUrl(); // } // // @JsonProperty("avatar_url") // public void setAvatarUrl(final String avatarUrl) { // mResponseAvatar.setAvatarUrl(avatarUrl); // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // mResponseAvatar.writeToParcel(dest, flags); // // dest.writeString(mPageText); // dest.writeString(mDateLine); // dest.writeString(mPostId); // dest.writeString(mType); // dest.writeString(mUserId); // dest.writeString(mUserName); // dest.writeString(mMentionedUserId); // dest.writeString(mMentionedUsername); // dest.writeString(mMentionedUserGroupId); // dest.writeString(mMentionedInfractionGroupId); // mThread.writeToParcel(dest, flags); // } // }
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.xda.one.api.model.interfaces.Mention; import com.xda.one.api.model.interfaces.container.MentionContainer; import com.xda.one.api.model.response.ResponseMention; import java.util.ArrayList; import java.util.List;
package com.xda.one.api.model.response.container; @JsonIgnoreProperties(ignoreUnknown = true) public class ResponseMentionContainer implements MentionContainer { @JsonProperty("results") private List<ResponseMention> mMentions = new ArrayList<>(); @JsonProperty("total_pages") private int mTotalPages; @JsonProperty("per_page") private int mPerPage; @JsonProperty("current_page") private int mCurrentPage; @Override
// Path: android/src/main/java/com/xda/one/api/model/interfaces/Mention.java // public interface Mention extends Parcelable { // // public String getPageText(); // // public String getDateLine(); // // public String getPostId(); // // public String getType(); // // String getUserId(); // // public String getUserName(); // // public String getMentionedUserId(); // // public String getMentionedUsername(); // // public String getMentionedUserGroupId(); // // public String getMentionedInfractionGroupId(); // // public UnifiedThread getThread(); // // String getAvatarUrl(); // } // // Path: android/src/main/java/com/xda/one/api/model/response/ResponseMention.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class ResponseMention implements Mention { // // public static final Creator<ResponseMention> CREATOR = new Creator<ResponseMention>() { // @Override // public ResponseMention createFromParcel(Parcel source) { // return new ResponseMention(source); // } // // @Override // public ResponseMention[] newArray(int size) { // return new ResponseMention[size]; // } // }; // // private final ResponseAvatar mResponseAvatar; // // @JsonProperty("pagetext") // private String mPageText; // // @JsonProperty("dateline") // private String mDateLine; // // @JsonProperty("postid") // private String mPostId; // // @JsonProperty("type") // private String mType; // // @JsonProperty("userid") // private String mUserId; // // @JsonProperty("username") // private String mUserName; // // @JsonProperty("mentioneduserid") // private String mMentionedUserId; // // @JsonProperty("mentionedusername") // private String mMentionedUsername; // // @JsonProperty("mentionedusergroupid") // private String mMentionedUserGroupId; // // @JsonProperty("mentionedinfractiongroupid") // private String mMentionedInfractionGroupId; // // @JsonProperty("thread") // private ResponseUnifiedThread mThread; // // public ResponseMention() { // mResponseAvatar = new ResponseAvatar(); // } // // public ResponseMention(Parcel in) { // mResponseAvatar = new ResponseAvatar(in); // // mPageText = in.readString(); // mDateLine = in.readString(); // mPostId = in.readString(); // mType = in.readString(); // mUserId = in.readString(); // mUserName = in.readString(); // mMentionedUserId = in.readString(); // mMentionedUsername = in.readString(); // mMentionedUserGroupId = in.readString(); // mMentionedInfractionGroupId = in.readString(); // mThread = in.readParcelable(UnifiedThread.class.getClassLoader()); // } // // @Override // public String getPageText() { // return mPageText; // } // // @Override // public String getDateLine() { // return mDateLine; // } // // @Override // public String getPostId() { // return mPostId; // } // // @Override // public String getType() { // return mType; // } // // @Override // public String getUserId() { // return mUserId; // } // // @Override // public String getUserName() { // return mUserName; // } // // @Override // public String getMentionedUserId() { // return mMentionedUserId; // } // // @Override // public String getMentionedUsername() { // return mMentionedUsername; // } // // @Override // public String getMentionedUserGroupId() { // return mMentionedUserGroupId; // } // // @Override // public String getMentionedInfractionGroupId() { // return mMentionedInfractionGroupId; // } // // @Override // public UnifiedThread getThread() { // return mThread; // } // // @Override // public String getAvatarUrl() { // return mResponseAvatar.getAvatarUrl(); // } // // @JsonProperty("avatar_url") // public void setAvatarUrl(final String avatarUrl) { // mResponseAvatar.setAvatarUrl(avatarUrl); // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // mResponseAvatar.writeToParcel(dest, flags); // // dest.writeString(mPageText); // dest.writeString(mDateLine); // dest.writeString(mPostId); // dest.writeString(mType); // dest.writeString(mUserId); // dest.writeString(mUserName); // dest.writeString(mMentionedUserId); // dest.writeString(mMentionedUsername); // dest.writeString(mMentionedUserGroupId); // dest.writeString(mMentionedInfractionGroupId); // mThread.writeToParcel(dest, flags); // } // } // Path: android/src/main/java/com/xda/one/api/model/response/container/ResponseMentionContainer.java import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.xda.one.api.model.interfaces.Mention; import com.xda.one.api.model.interfaces.container.MentionContainer; import com.xda.one.api.model.response.ResponseMention; import java.util.ArrayList; import java.util.List; package com.xda.one.api.model.response.container; @JsonIgnoreProperties(ignoreUnknown = true) public class ResponseMentionContainer implements MentionContainer { @JsonProperty("results") private List<ResponseMention> mMentions = new ArrayList<>(); @JsonProperty("total_pages") private int mTotalPages; @JsonProperty("per_page") private int mPerPage; @JsonProperty("current_page") private int mCurrentPage; @Override
public List<? extends Mention> getMentions() {
xda/XDA-One
android/src/main/java/com/xda/one/ui/NavigationDrawerAdapter.java
// Path: android/src/main/java/com/xda/one/auth/XDAAccount.java // public class XDAAccount extends Account { // // public static final Creator<XDAAccount> CREATOR = new Creator<XDAAccount>() { // @Override // public XDAAccount createFromParcel(Parcel source) { // return new XDAAccount(source); // } // // @Override // public XDAAccount[] newArray(int size) { // return new XDAAccount[size]; // } // }; // // private final String mEmail; // // private final String mUserId; // // private final String mAvatarUrl; // // private final int mPmCount; // // private final int mQuoteCount; // // private final int mMentionCount; // // private final String mAuthToken; // // public XDAAccount(final String name, final String userId, final String email, // final String avatarUrl, final int pmCount, final int quoteCount, // final int mentionCount, final String authToken) { // super(name, "com.xda"); // mEmail = email; // mUserId = userId; // mAvatarUrl = avatarUrl; // mPmCount = pmCount; // mQuoteCount = quoteCount; // mMentionCount = mentionCount; // // mAuthToken = authToken; // } // // public XDAAccount(final Parcel source) { // super(source); // // mEmail = source.readString(); // mUserId = source.readString(); // mAvatarUrl = source.readString(); // mPmCount = source.readInt(); // mQuoteCount = source.readInt(); // mMentionCount = source.readInt(); // mAuthToken = source.readString(); // } // // public static XDAAccount fromProfile(final ResponseUserProfile profile) { // final ResponseUserProfileNotificationContainer notifications = profile.getNotifications(); // return new XDAAccount(profile.getUserName(), profile.getUserId(), profile.getEmail(), // profile.getAvatarUrl(), notifications.getPmUnread().getTotal(), // notifications.getDbTechQuoteCount().getTotal(), // notifications.getDbTechMetionCount().getTotal(), // RetrofitClient.getAuthToken()); // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // super.writeToParcel(dest, flags); // // dest.writeString(mEmail); // dest.writeString(mUserId); // dest.writeString(mAvatarUrl); // dest.writeInt(mPmCount); // dest.writeInt(mQuoteCount); // dest.writeInt(mMentionCount); // dest.writeString(mAuthToken); // } // // public String getEmail() { // return mEmail; // } // // public String getUserId() { // return mUserId; // } // // public String getAvatarUrl() { // return mAvatarUrl; // } // // public String getUserName() { // return name; // } // // public int getPmCount() { // return mPmCount; // } // // public int getQuoteCount() { // return mQuoteCount; // } // // public int getMentionCount() { // return mMentionCount; // } // // public String getAuthToken() { // return mAuthToken; // } // }
import com.xda.one.R; import com.xda.one.auth.XDAAccount; import android.content.Context; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.TextView; import java.util.ArrayList; import java.util.List;
if (convertView == null) { convertView = mLayoutInflater .inflate(R.layout.navigation_drawer_list_item, parent, false); holder = new ViewHolder(); holder.iconView = (ImageView) convertView.findViewById(R.id .navigation_drawer_list_item_icon); holder.titleView = (TextView) convertView.findViewById(R.id .navigation_drawer_list_item_title); holder.countView = (TextView) convertView.findViewById(R.id .navigation_drawer_list_item_count); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.iconView.setImageResource(item.getDrawableId()); holder.titleView.setText(mContext.getString(item.getTitleId())); // Remove the count view for now if (TextUtils.isEmpty(item.getCountString())) { holder.countView.setVisibility(View.GONE); } else { holder.countView.setVisibility(View.VISIBLE); holder.countView.setText(item.getCountString()); } return convertView; }
// Path: android/src/main/java/com/xda/one/auth/XDAAccount.java // public class XDAAccount extends Account { // // public static final Creator<XDAAccount> CREATOR = new Creator<XDAAccount>() { // @Override // public XDAAccount createFromParcel(Parcel source) { // return new XDAAccount(source); // } // // @Override // public XDAAccount[] newArray(int size) { // return new XDAAccount[size]; // } // }; // // private final String mEmail; // // private final String mUserId; // // private final String mAvatarUrl; // // private final int mPmCount; // // private final int mQuoteCount; // // private final int mMentionCount; // // private final String mAuthToken; // // public XDAAccount(final String name, final String userId, final String email, // final String avatarUrl, final int pmCount, final int quoteCount, // final int mentionCount, final String authToken) { // super(name, "com.xda"); // mEmail = email; // mUserId = userId; // mAvatarUrl = avatarUrl; // mPmCount = pmCount; // mQuoteCount = quoteCount; // mMentionCount = mentionCount; // // mAuthToken = authToken; // } // // public XDAAccount(final Parcel source) { // super(source); // // mEmail = source.readString(); // mUserId = source.readString(); // mAvatarUrl = source.readString(); // mPmCount = source.readInt(); // mQuoteCount = source.readInt(); // mMentionCount = source.readInt(); // mAuthToken = source.readString(); // } // // public static XDAAccount fromProfile(final ResponseUserProfile profile) { // final ResponseUserProfileNotificationContainer notifications = profile.getNotifications(); // return new XDAAccount(profile.getUserName(), profile.getUserId(), profile.getEmail(), // profile.getAvatarUrl(), notifications.getPmUnread().getTotal(), // notifications.getDbTechQuoteCount().getTotal(), // notifications.getDbTechMetionCount().getTotal(), // RetrofitClient.getAuthToken()); // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // super.writeToParcel(dest, flags); // // dest.writeString(mEmail); // dest.writeString(mUserId); // dest.writeString(mAvatarUrl); // dest.writeInt(mPmCount); // dest.writeInt(mQuoteCount); // dest.writeInt(mMentionCount); // dest.writeString(mAuthToken); // } // // public String getEmail() { // return mEmail; // } // // public String getUserId() { // return mUserId; // } // // public String getAvatarUrl() { // return mAvatarUrl; // } // // public String getUserName() { // return name; // } // // public int getPmCount() { // return mPmCount; // } // // public int getQuoteCount() { // return mQuoteCount; // } // // public int getMentionCount() { // return mMentionCount; // } // // public String getAuthToken() { // return mAuthToken; // } // } // Path: android/src/main/java/com/xda/one/ui/NavigationDrawerAdapter.java import com.xda.one.R; import com.xda.one.auth.XDAAccount; import android.content.Context; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.TextView; import java.util.ArrayList; import java.util.List; if (convertView == null) { convertView = mLayoutInflater .inflate(R.layout.navigation_drawer_list_item, parent, false); holder = new ViewHolder(); holder.iconView = (ImageView) convertView.findViewById(R.id .navigation_drawer_list_item_icon); holder.titleView = (TextView) convertView.findViewById(R.id .navigation_drawer_list_item_title); holder.countView = (TextView) convertView.findViewById(R.id .navigation_drawer_list_item_count); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.iconView.setImageResource(item.getDrawableId()); holder.titleView.setText(mContext.getString(item.getTitleId())); // Remove the count view for now if (TextUtils.isEmpty(item.getCountString())) { holder.countView.setVisibility(View.GONE); } else { holder.countView.setVisibility(View.VISIBLE); holder.countView.setText(item.getCountString()); } return convertView; }
public void onUserProfileChanged(final XDAAccount account) {
asebak/ui5-intellij-plugin
src/com/atsebak/ui5/projectbuilder/UI5ProjectTemplateGenerator.java
// Path: src/com/atsebak/ui5/AppType.java // public enum AppType { // DESKTOP, // MOBILE // } // // Path: src/com/atsebak/ui5/FileType.java // public enum FileType { // JS, // XML, // HTML, // JSON, // PROPERTIES // } // // Path: src/com/atsebak/ui5/autogeneration/Controller.java // public class Controller extends UI5View { // /** // * generates code for the controller // * // * @param modulePath // * @param controllerName // * @return // */ // @NotNull // public String getAutogenerateCode(@NotNull String modulePath, @NotNull String controllerName) { // return getCodeGenerator().createControllerCode(modulePath + "." + controllerName); // } // } // // Path: src/com/atsebak/ui5/autogeneration/Index.java // public class Index extends UI5View { // @NotNull // public String createIndexCode(@NotNull AppType ui5Library, @NotNull String rootModuleName, @NotNull String initialViewExt) { // return getCodeGenerator().createIndexCode(ui5Library, rootModuleName, initialViewExt); // } // } // // Path: src/com/atsebak/ui5/autogeneration/UI5View.java // @NoArgsConstructor // public abstract class UI5View { // @Getter // private final CodeGenerator codeGenerator = new CodeGenerator(); // @Getter // private String extension; // // public UI5View(@NotNull String extension) { // this.extension = extension; // } // // /** // * Given the application type and the module path for generation // * @param appType // * @param controllerPath // * @return // */ // public String generateCode(AppType appType, String controllerPath) { // return codeGenerator.createViewCode(appType, controllerPath, extension); // } // } // // Path: src/com/atsebak/ui5/locale/UI5Bundle.java // public final class UI5Bundle { // // @NonNls // private static final String BUNDLE = "com.atsebak.ui5.locale.UI5Bundle"; // private static Reference<ResourceBundle> bundleReference; // // /** // * Private Constructor // */ // private UI5Bundle() { // } // // /** // * @param key // * @param params // * @return // */ // public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { // return BundleBase.message(getBundle(), key, params); // } // // /** // * @return // */ // private static ResourceBundle getBundle() { // ResourceBundle bundle = dereference(bundleReference); // if (bundle == null) { // bundle = ResourceBundle.getBundle(BUNDLE); // bundleReference = new SoftReference<ResourceBundle>(bundle); // } // return bundle; // } // // /** // * @param key The Key // * @return The Localized Text // */ // public static String getString(@PropertyKey(resourceBundle = BUNDLE) final String key) { // return getBundle().getString(key); // } // } // // Path: src/com/atsebak/ui5/util/Writer.java // public final class Writer { // // /** // * Private constructor // */ // private Writer() { // // } // /** // * Writes content to a specific file // * @param file // * @param content // * @throws IOException // */ // public static void writeToFile(@NotNull File file,@NotNull String content) throws IOException { // BufferedWriter bw = new BufferedWriter(new FileWriter(file)); // bw.write(content); // bw.close(); // } // }
import com.atsebak.ui5.AppType; import com.atsebak.ui5.FileType; import com.atsebak.ui5.autogeneration.Controller; import com.atsebak.ui5.autogeneration.Index; import com.atsebak.ui5.autogeneration.UI5View; import com.atsebak.ui5.locale.UI5Bundle; import com.atsebak.ui5.util.*; import com.atsebak.ui5.util.Writer; import com.intellij.ide.util.projectWizard.WebProjectTemplate; import com.intellij.openapi.module.Module; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VirtualFile; import lombok.Data; import lombok.SneakyThrows; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.io.*;
package com.atsebak.ui5.projectbuilder; /** * This is for the sub template of the project. * Once the finished but is click generateProject method is called and runs a separate process */ public class UI5ProjectTemplateGenerator extends WebProjectTemplate<UI5ProjectTemplateGenerator.UI5ProjectSettings> { private static final String UI5_RESOURCE_PATH = "/ui5/"; private static final String RESOURCE_PATH = UI5_RESOURCE_PATH + "ui5/resources.zip"; @Nls @NotNull @Override public String getName() {
// Path: src/com/atsebak/ui5/AppType.java // public enum AppType { // DESKTOP, // MOBILE // } // // Path: src/com/atsebak/ui5/FileType.java // public enum FileType { // JS, // XML, // HTML, // JSON, // PROPERTIES // } // // Path: src/com/atsebak/ui5/autogeneration/Controller.java // public class Controller extends UI5View { // /** // * generates code for the controller // * // * @param modulePath // * @param controllerName // * @return // */ // @NotNull // public String getAutogenerateCode(@NotNull String modulePath, @NotNull String controllerName) { // return getCodeGenerator().createControllerCode(modulePath + "." + controllerName); // } // } // // Path: src/com/atsebak/ui5/autogeneration/Index.java // public class Index extends UI5View { // @NotNull // public String createIndexCode(@NotNull AppType ui5Library, @NotNull String rootModuleName, @NotNull String initialViewExt) { // return getCodeGenerator().createIndexCode(ui5Library, rootModuleName, initialViewExt); // } // } // // Path: src/com/atsebak/ui5/autogeneration/UI5View.java // @NoArgsConstructor // public abstract class UI5View { // @Getter // private final CodeGenerator codeGenerator = new CodeGenerator(); // @Getter // private String extension; // // public UI5View(@NotNull String extension) { // this.extension = extension; // } // // /** // * Given the application type and the module path for generation // * @param appType // * @param controllerPath // * @return // */ // public String generateCode(AppType appType, String controllerPath) { // return codeGenerator.createViewCode(appType, controllerPath, extension); // } // } // // Path: src/com/atsebak/ui5/locale/UI5Bundle.java // public final class UI5Bundle { // // @NonNls // private static final String BUNDLE = "com.atsebak.ui5.locale.UI5Bundle"; // private static Reference<ResourceBundle> bundleReference; // // /** // * Private Constructor // */ // private UI5Bundle() { // } // // /** // * @param key // * @param params // * @return // */ // public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { // return BundleBase.message(getBundle(), key, params); // } // // /** // * @return // */ // private static ResourceBundle getBundle() { // ResourceBundle bundle = dereference(bundleReference); // if (bundle == null) { // bundle = ResourceBundle.getBundle(BUNDLE); // bundleReference = new SoftReference<ResourceBundle>(bundle); // } // return bundle; // } // // /** // * @param key The Key // * @return The Localized Text // */ // public static String getString(@PropertyKey(resourceBundle = BUNDLE) final String key) { // return getBundle().getString(key); // } // } // // Path: src/com/atsebak/ui5/util/Writer.java // public final class Writer { // // /** // * Private constructor // */ // private Writer() { // // } // /** // * Writes content to a specific file // * @param file // * @param content // * @throws IOException // */ // public static void writeToFile(@NotNull File file,@NotNull String content) throws IOException { // BufferedWriter bw = new BufferedWriter(new FileWriter(file)); // bw.write(content); // bw.close(); // } // } // Path: src/com/atsebak/ui5/projectbuilder/UI5ProjectTemplateGenerator.java import com.atsebak.ui5.AppType; import com.atsebak.ui5.FileType; import com.atsebak.ui5.autogeneration.Controller; import com.atsebak.ui5.autogeneration.Index; import com.atsebak.ui5.autogeneration.UI5View; import com.atsebak.ui5.locale.UI5Bundle; import com.atsebak.ui5.util.*; import com.atsebak.ui5.util.Writer; import com.intellij.ide.util.projectWizard.WebProjectTemplate; import com.intellij.openapi.module.Module; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VirtualFile; import lombok.Data; import lombok.SneakyThrows; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.io.*; package com.atsebak.ui5.projectbuilder; /** * This is for the sub template of the project. * Once the finished but is click generateProject method is called and runs a separate process */ public class UI5ProjectTemplateGenerator extends WebProjectTemplate<UI5ProjectTemplateGenerator.UI5ProjectSettings> { private static final String UI5_RESOURCE_PATH = "/ui5/"; private static final String RESOURCE_PATH = UI5_RESOURCE_PATH + "ui5/resources.zip"; @Nls @NotNull @Override public String getName() {
return UI5Bundle.getString("app");
asebak/ui5-intellij-plugin
src/com/atsebak/ui5/projectbuilder/UI5ProjectTemplateGenerator.java
// Path: src/com/atsebak/ui5/AppType.java // public enum AppType { // DESKTOP, // MOBILE // } // // Path: src/com/atsebak/ui5/FileType.java // public enum FileType { // JS, // XML, // HTML, // JSON, // PROPERTIES // } // // Path: src/com/atsebak/ui5/autogeneration/Controller.java // public class Controller extends UI5View { // /** // * generates code for the controller // * // * @param modulePath // * @param controllerName // * @return // */ // @NotNull // public String getAutogenerateCode(@NotNull String modulePath, @NotNull String controllerName) { // return getCodeGenerator().createControllerCode(modulePath + "." + controllerName); // } // } // // Path: src/com/atsebak/ui5/autogeneration/Index.java // public class Index extends UI5View { // @NotNull // public String createIndexCode(@NotNull AppType ui5Library, @NotNull String rootModuleName, @NotNull String initialViewExt) { // return getCodeGenerator().createIndexCode(ui5Library, rootModuleName, initialViewExt); // } // } // // Path: src/com/atsebak/ui5/autogeneration/UI5View.java // @NoArgsConstructor // public abstract class UI5View { // @Getter // private final CodeGenerator codeGenerator = new CodeGenerator(); // @Getter // private String extension; // // public UI5View(@NotNull String extension) { // this.extension = extension; // } // // /** // * Given the application type and the module path for generation // * @param appType // * @param controllerPath // * @return // */ // public String generateCode(AppType appType, String controllerPath) { // return codeGenerator.createViewCode(appType, controllerPath, extension); // } // } // // Path: src/com/atsebak/ui5/locale/UI5Bundle.java // public final class UI5Bundle { // // @NonNls // private static final String BUNDLE = "com.atsebak.ui5.locale.UI5Bundle"; // private static Reference<ResourceBundle> bundleReference; // // /** // * Private Constructor // */ // private UI5Bundle() { // } // // /** // * @param key // * @param params // * @return // */ // public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { // return BundleBase.message(getBundle(), key, params); // } // // /** // * @return // */ // private static ResourceBundle getBundle() { // ResourceBundle bundle = dereference(bundleReference); // if (bundle == null) { // bundle = ResourceBundle.getBundle(BUNDLE); // bundleReference = new SoftReference<ResourceBundle>(bundle); // } // return bundle; // } // // /** // * @param key The Key // * @return The Localized Text // */ // public static String getString(@PropertyKey(resourceBundle = BUNDLE) final String key) { // return getBundle().getString(key); // } // } // // Path: src/com/atsebak/ui5/util/Writer.java // public final class Writer { // // /** // * Private constructor // */ // private Writer() { // // } // /** // * Writes content to a specific file // * @param file // * @param content // * @throws IOException // */ // public static void writeToFile(@NotNull File file,@NotNull String content) throws IOException { // BufferedWriter bw = new BufferedWriter(new FileWriter(file)); // bw.write(content); // bw.close(); // } // }
import com.atsebak.ui5.AppType; import com.atsebak.ui5.FileType; import com.atsebak.ui5.autogeneration.Controller; import com.atsebak.ui5.autogeneration.Index; import com.atsebak.ui5.autogeneration.UI5View; import com.atsebak.ui5.locale.UI5Bundle; import com.atsebak.ui5.util.*; import com.atsebak.ui5.util.Writer; import com.intellij.ide.util.projectWizard.WebProjectTemplate; import com.intellij.openapi.module.Module; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VirtualFile; import lombok.Data; import lombok.SneakyThrows; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.io.*;
package com.atsebak.ui5.projectbuilder; /** * This is for the sub template of the project. * Once the finished but is click generateProject method is called and runs a separate process */ public class UI5ProjectTemplateGenerator extends WebProjectTemplate<UI5ProjectTemplateGenerator.UI5ProjectSettings> { private static final String UI5_RESOURCE_PATH = "/ui5/"; private static final String RESOURCE_PATH = UI5_RESOURCE_PATH + "ui5/resources.zip"; @Nls @NotNull @Override public String getName() { return UI5Bundle.getString("app"); } @Override public String getDescription() { return UI5Bundle.getString("app.description"); } @Override public void generateProject(@NotNull final Project project, @NotNull final VirtualFile virtualFile, @NotNull final UI5ProjectSettings settings, @NotNull Module module) { if (settings.getLibrary() == null) {
// Path: src/com/atsebak/ui5/AppType.java // public enum AppType { // DESKTOP, // MOBILE // } // // Path: src/com/atsebak/ui5/FileType.java // public enum FileType { // JS, // XML, // HTML, // JSON, // PROPERTIES // } // // Path: src/com/atsebak/ui5/autogeneration/Controller.java // public class Controller extends UI5View { // /** // * generates code for the controller // * // * @param modulePath // * @param controllerName // * @return // */ // @NotNull // public String getAutogenerateCode(@NotNull String modulePath, @NotNull String controllerName) { // return getCodeGenerator().createControllerCode(modulePath + "." + controllerName); // } // } // // Path: src/com/atsebak/ui5/autogeneration/Index.java // public class Index extends UI5View { // @NotNull // public String createIndexCode(@NotNull AppType ui5Library, @NotNull String rootModuleName, @NotNull String initialViewExt) { // return getCodeGenerator().createIndexCode(ui5Library, rootModuleName, initialViewExt); // } // } // // Path: src/com/atsebak/ui5/autogeneration/UI5View.java // @NoArgsConstructor // public abstract class UI5View { // @Getter // private final CodeGenerator codeGenerator = new CodeGenerator(); // @Getter // private String extension; // // public UI5View(@NotNull String extension) { // this.extension = extension; // } // // /** // * Given the application type and the module path for generation // * @param appType // * @param controllerPath // * @return // */ // public String generateCode(AppType appType, String controllerPath) { // return codeGenerator.createViewCode(appType, controllerPath, extension); // } // } // // Path: src/com/atsebak/ui5/locale/UI5Bundle.java // public final class UI5Bundle { // // @NonNls // private static final String BUNDLE = "com.atsebak.ui5.locale.UI5Bundle"; // private static Reference<ResourceBundle> bundleReference; // // /** // * Private Constructor // */ // private UI5Bundle() { // } // // /** // * @param key // * @param params // * @return // */ // public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { // return BundleBase.message(getBundle(), key, params); // } // // /** // * @return // */ // private static ResourceBundle getBundle() { // ResourceBundle bundle = dereference(bundleReference); // if (bundle == null) { // bundle = ResourceBundle.getBundle(BUNDLE); // bundleReference = new SoftReference<ResourceBundle>(bundle); // } // return bundle; // } // // /** // * @param key The Key // * @return The Localized Text // */ // public static String getString(@PropertyKey(resourceBundle = BUNDLE) final String key) { // return getBundle().getString(key); // } // } // // Path: src/com/atsebak/ui5/util/Writer.java // public final class Writer { // // /** // * Private constructor // */ // private Writer() { // // } // /** // * Writes content to a specific file // * @param file // * @param content // * @throws IOException // */ // public static void writeToFile(@NotNull File file,@NotNull String content) throws IOException { // BufferedWriter bw = new BufferedWriter(new FileWriter(file)); // bw.write(content); // bw.close(); // } // } // Path: src/com/atsebak/ui5/projectbuilder/UI5ProjectTemplateGenerator.java import com.atsebak.ui5.AppType; import com.atsebak.ui5.FileType; import com.atsebak.ui5.autogeneration.Controller; import com.atsebak.ui5.autogeneration.Index; import com.atsebak.ui5.autogeneration.UI5View; import com.atsebak.ui5.locale.UI5Bundle; import com.atsebak.ui5.util.*; import com.atsebak.ui5.util.Writer; import com.intellij.ide.util.projectWizard.WebProjectTemplate; import com.intellij.openapi.module.Module; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VirtualFile; import lombok.Data; import lombok.SneakyThrows; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.io.*; package com.atsebak.ui5.projectbuilder; /** * This is for the sub template of the project. * Once the finished but is click generateProject method is called and runs a separate process */ public class UI5ProjectTemplateGenerator extends WebProjectTemplate<UI5ProjectTemplateGenerator.UI5ProjectSettings> { private static final String UI5_RESOURCE_PATH = "/ui5/"; private static final String RESOURCE_PATH = UI5_RESOURCE_PATH + "ui5/resources.zip"; @Nls @NotNull @Override public String getName() { return UI5Bundle.getString("app"); } @Override public String getDescription() { return UI5Bundle.getString("app.description"); } @Override public void generateProject(@NotNull final Project project, @NotNull final VirtualFile virtualFile, @NotNull final UI5ProjectSettings settings, @NotNull Module module) { if (settings.getLibrary() == null) {
settings.setLibrary(AppType.DESKTOP);
asebak/ui5-intellij-plugin
src/com/atsebak/ui5/projectbuilder/UI5ProjectTemplateGenerator.java
// Path: src/com/atsebak/ui5/AppType.java // public enum AppType { // DESKTOP, // MOBILE // } // // Path: src/com/atsebak/ui5/FileType.java // public enum FileType { // JS, // XML, // HTML, // JSON, // PROPERTIES // } // // Path: src/com/atsebak/ui5/autogeneration/Controller.java // public class Controller extends UI5View { // /** // * generates code for the controller // * // * @param modulePath // * @param controllerName // * @return // */ // @NotNull // public String getAutogenerateCode(@NotNull String modulePath, @NotNull String controllerName) { // return getCodeGenerator().createControllerCode(modulePath + "." + controllerName); // } // } // // Path: src/com/atsebak/ui5/autogeneration/Index.java // public class Index extends UI5View { // @NotNull // public String createIndexCode(@NotNull AppType ui5Library, @NotNull String rootModuleName, @NotNull String initialViewExt) { // return getCodeGenerator().createIndexCode(ui5Library, rootModuleName, initialViewExt); // } // } // // Path: src/com/atsebak/ui5/autogeneration/UI5View.java // @NoArgsConstructor // public abstract class UI5View { // @Getter // private final CodeGenerator codeGenerator = new CodeGenerator(); // @Getter // private String extension; // // public UI5View(@NotNull String extension) { // this.extension = extension; // } // // /** // * Given the application type and the module path for generation // * @param appType // * @param controllerPath // * @return // */ // public String generateCode(AppType appType, String controllerPath) { // return codeGenerator.createViewCode(appType, controllerPath, extension); // } // } // // Path: src/com/atsebak/ui5/locale/UI5Bundle.java // public final class UI5Bundle { // // @NonNls // private static final String BUNDLE = "com.atsebak.ui5.locale.UI5Bundle"; // private static Reference<ResourceBundle> bundleReference; // // /** // * Private Constructor // */ // private UI5Bundle() { // } // // /** // * @param key // * @param params // * @return // */ // public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { // return BundleBase.message(getBundle(), key, params); // } // // /** // * @return // */ // private static ResourceBundle getBundle() { // ResourceBundle bundle = dereference(bundleReference); // if (bundle == null) { // bundle = ResourceBundle.getBundle(BUNDLE); // bundleReference = new SoftReference<ResourceBundle>(bundle); // } // return bundle; // } // // /** // * @param key The Key // * @return The Localized Text // */ // public static String getString(@PropertyKey(resourceBundle = BUNDLE) final String key) { // return getBundle().getString(key); // } // } // // Path: src/com/atsebak/ui5/util/Writer.java // public final class Writer { // // /** // * Private constructor // */ // private Writer() { // // } // /** // * Writes content to a specific file // * @param file // * @param content // * @throws IOException // */ // public static void writeToFile(@NotNull File file,@NotNull String content) throws IOException { // BufferedWriter bw = new BufferedWriter(new FileWriter(file)); // bw.write(content); // bw.close(); // } // }
import com.atsebak.ui5.AppType; import com.atsebak.ui5.FileType; import com.atsebak.ui5.autogeneration.Controller; import com.atsebak.ui5.autogeneration.Index; import com.atsebak.ui5.autogeneration.UI5View; import com.atsebak.ui5.locale.UI5Bundle; import com.atsebak.ui5.util.*; import com.atsebak.ui5.util.Writer; import com.intellij.ide.util.projectWizard.WebProjectTemplate; import com.intellij.openapi.module.Module; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VirtualFile; import lombok.Data; import lombok.SneakyThrows; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.io.*;
package com.atsebak.ui5.projectbuilder; /** * This is for the sub template of the project. * Once the finished but is click generateProject method is called and runs a separate process */ public class UI5ProjectTemplateGenerator extends WebProjectTemplate<UI5ProjectTemplateGenerator.UI5ProjectSettings> { private static final String UI5_RESOURCE_PATH = "/ui5/"; private static final String RESOURCE_PATH = UI5_RESOURCE_PATH + "ui5/resources.zip"; @Nls @NotNull @Override public String getName() { return UI5Bundle.getString("app"); } @Override public String getDescription() { return UI5Bundle.getString("app.description"); } @Override public void generateProject(@NotNull final Project project, @NotNull final VirtualFile virtualFile, @NotNull final UI5ProjectSettings settings, @NotNull Module module) { if (settings.getLibrary() == null) { settings.setLibrary(AppType.DESKTOP); }
// Path: src/com/atsebak/ui5/AppType.java // public enum AppType { // DESKTOP, // MOBILE // } // // Path: src/com/atsebak/ui5/FileType.java // public enum FileType { // JS, // XML, // HTML, // JSON, // PROPERTIES // } // // Path: src/com/atsebak/ui5/autogeneration/Controller.java // public class Controller extends UI5View { // /** // * generates code for the controller // * // * @param modulePath // * @param controllerName // * @return // */ // @NotNull // public String getAutogenerateCode(@NotNull String modulePath, @NotNull String controllerName) { // return getCodeGenerator().createControllerCode(modulePath + "." + controllerName); // } // } // // Path: src/com/atsebak/ui5/autogeneration/Index.java // public class Index extends UI5View { // @NotNull // public String createIndexCode(@NotNull AppType ui5Library, @NotNull String rootModuleName, @NotNull String initialViewExt) { // return getCodeGenerator().createIndexCode(ui5Library, rootModuleName, initialViewExt); // } // } // // Path: src/com/atsebak/ui5/autogeneration/UI5View.java // @NoArgsConstructor // public abstract class UI5View { // @Getter // private final CodeGenerator codeGenerator = new CodeGenerator(); // @Getter // private String extension; // // public UI5View(@NotNull String extension) { // this.extension = extension; // } // // /** // * Given the application type and the module path for generation // * @param appType // * @param controllerPath // * @return // */ // public String generateCode(AppType appType, String controllerPath) { // return codeGenerator.createViewCode(appType, controllerPath, extension); // } // } // // Path: src/com/atsebak/ui5/locale/UI5Bundle.java // public final class UI5Bundle { // // @NonNls // private static final String BUNDLE = "com.atsebak.ui5.locale.UI5Bundle"; // private static Reference<ResourceBundle> bundleReference; // // /** // * Private Constructor // */ // private UI5Bundle() { // } // // /** // * @param key // * @param params // * @return // */ // public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { // return BundleBase.message(getBundle(), key, params); // } // // /** // * @return // */ // private static ResourceBundle getBundle() { // ResourceBundle bundle = dereference(bundleReference); // if (bundle == null) { // bundle = ResourceBundle.getBundle(BUNDLE); // bundleReference = new SoftReference<ResourceBundle>(bundle); // } // return bundle; // } // // /** // * @param key The Key // * @return The Localized Text // */ // public static String getString(@PropertyKey(resourceBundle = BUNDLE) final String key) { // return getBundle().getString(key); // } // } // // Path: src/com/atsebak/ui5/util/Writer.java // public final class Writer { // // /** // * Private constructor // */ // private Writer() { // // } // /** // * Writes content to a specific file // * @param file // * @param content // * @throws IOException // */ // public static void writeToFile(@NotNull File file,@NotNull String content) throws IOException { // BufferedWriter bw = new BufferedWriter(new FileWriter(file)); // bw.write(content); // bw.close(); // } // } // Path: src/com/atsebak/ui5/projectbuilder/UI5ProjectTemplateGenerator.java import com.atsebak.ui5.AppType; import com.atsebak.ui5.FileType; import com.atsebak.ui5.autogeneration.Controller; import com.atsebak.ui5.autogeneration.Index; import com.atsebak.ui5.autogeneration.UI5View; import com.atsebak.ui5.locale.UI5Bundle; import com.atsebak.ui5.util.*; import com.atsebak.ui5.util.Writer; import com.intellij.ide.util.projectWizard.WebProjectTemplate; import com.intellij.openapi.module.Module; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VirtualFile; import lombok.Data; import lombok.SneakyThrows; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.io.*; package com.atsebak.ui5.projectbuilder; /** * This is for the sub template of the project. * Once the finished but is click generateProject method is called and runs a separate process */ public class UI5ProjectTemplateGenerator extends WebProjectTemplate<UI5ProjectTemplateGenerator.UI5ProjectSettings> { private static final String UI5_RESOURCE_PATH = "/ui5/"; private static final String RESOURCE_PATH = UI5_RESOURCE_PATH + "ui5/resources.zip"; @Nls @NotNull @Override public String getName() { return UI5Bundle.getString("app"); } @Override public String getDescription() { return UI5Bundle.getString("app.description"); } @Override public void generateProject(@NotNull final Project project, @NotNull final VirtualFile virtualFile, @NotNull final UI5ProjectSettings settings, @NotNull Module module) { if (settings.getLibrary() == null) { settings.setLibrary(AppType.DESKTOP); }
final Index index = new Index();
asebak/ui5-intellij-plugin
src/com/atsebak/ui5/projectbuilder/UI5ProjectTemplateGenerator.java
// Path: src/com/atsebak/ui5/AppType.java // public enum AppType { // DESKTOP, // MOBILE // } // // Path: src/com/atsebak/ui5/FileType.java // public enum FileType { // JS, // XML, // HTML, // JSON, // PROPERTIES // } // // Path: src/com/atsebak/ui5/autogeneration/Controller.java // public class Controller extends UI5View { // /** // * generates code for the controller // * // * @param modulePath // * @param controllerName // * @return // */ // @NotNull // public String getAutogenerateCode(@NotNull String modulePath, @NotNull String controllerName) { // return getCodeGenerator().createControllerCode(modulePath + "." + controllerName); // } // } // // Path: src/com/atsebak/ui5/autogeneration/Index.java // public class Index extends UI5View { // @NotNull // public String createIndexCode(@NotNull AppType ui5Library, @NotNull String rootModuleName, @NotNull String initialViewExt) { // return getCodeGenerator().createIndexCode(ui5Library, rootModuleName, initialViewExt); // } // } // // Path: src/com/atsebak/ui5/autogeneration/UI5View.java // @NoArgsConstructor // public abstract class UI5View { // @Getter // private final CodeGenerator codeGenerator = new CodeGenerator(); // @Getter // private String extension; // // public UI5View(@NotNull String extension) { // this.extension = extension; // } // // /** // * Given the application type and the module path for generation // * @param appType // * @param controllerPath // * @return // */ // public String generateCode(AppType appType, String controllerPath) { // return codeGenerator.createViewCode(appType, controllerPath, extension); // } // } // // Path: src/com/atsebak/ui5/locale/UI5Bundle.java // public final class UI5Bundle { // // @NonNls // private static final String BUNDLE = "com.atsebak.ui5.locale.UI5Bundle"; // private static Reference<ResourceBundle> bundleReference; // // /** // * Private Constructor // */ // private UI5Bundle() { // } // // /** // * @param key // * @param params // * @return // */ // public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { // return BundleBase.message(getBundle(), key, params); // } // // /** // * @return // */ // private static ResourceBundle getBundle() { // ResourceBundle bundle = dereference(bundleReference); // if (bundle == null) { // bundle = ResourceBundle.getBundle(BUNDLE); // bundleReference = new SoftReference<ResourceBundle>(bundle); // } // return bundle; // } // // /** // * @param key The Key // * @return The Localized Text // */ // public static String getString(@PropertyKey(resourceBundle = BUNDLE) final String key) { // return getBundle().getString(key); // } // } // // Path: src/com/atsebak/ui5/util/Writer.java // public final class Writer { // // /** // * Private constructor // */ // private Writer() { // // } // /** // * Writes content to a specific file // * @param file // * @param content // * @throws IOException // */ // public static void writeToFile(@NotNull File file,@NotNull String content) throws IOException { // BufferedWriter bw = new BufferedWriter(new FileWriter(file)); // bw.write(content); // bw.close(); // } // }
import com.atsebak.ui5.AppType; import com.atsebak.ui5.FileType; import com.atsebak.ui5.autogeneration.Controller; import com.atsebak.ui5.autogeneration.Index; import com.atsebak.ui5.autogeneration.UI5View; import com.atsebak.ui5.locale.UI5Bundle; import com.atsebak.ui5.util.*; import com.atsebak.ui5.util.Writer; import com.intellij.ide.util.projectWizard.WebProjectTemplate; import com.intellij.openapi.module.Module; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VirtualFile; import lombok.Data; import lombok.SneakyThrows; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.io.*;
package com.atsebak.ui5.projectbuilder; /** * This is for the sub template of the project. * Once the finished but is click generateProject method is called and runs a separate process */ public class UI5ProjectTemplateGenerator extends WebProjectTemplate<UI5ProjectTemplateGenerator.UI5ProjectSettings> { private static final String UI5_RESOURCE_PATH = "/ui5/"; private static final String RESOURCE_PATH = UI5_RESOURCE_PATH + "ui5/resources.zip"; @Nls @NotNull @Override public String getName() { return UI5Bundle.getString("app"); } @Override public String getDescription() { return UI5Bundle.getString("app.description"); } @Override public void generateProject(@NotNull final Project project, @NotNull final VirtualFile virtualFile, @NotNull final UI5ProjectSettings settings, @NotNull Module module) { if (settings.getLibrary() == null) { settings.setLibrary(AppType.DESKTOP); } final Index index = new Index();
// Path: src/com/atsebak/ui5/AppType.java // public enum AppType { // DESKTOP, // MOBILE // } // // Path: src/com/atsebak/ui5/FileType.java // public enum FileType { // JS, // XML, // HTML, // JSON, // PROPERTIES // } // // Path: src/com/atsebak/ui5/autogeneration/Controller.java // public class Controller extends UI5View { // /** // * generates code for the controller // * // * @param modulePath // * @param controllerName // * @return // */ // @NotNull // public String getAutogenerateCode(@NotNull String modulePath, @NotNull String controllerName) { // return getCodeGenerator().createControllerCode(modulePath + "." + controllerName); // } // } // // Path: src/com/atsebak/ui5/autogeneration/Index.java // public class Index extends UI5View { // @NotNull // public String createIndexCode(@NotNull AppType ui5Library, @NotNull String rootModuleName, @NotNull String initialViewExt) { // return getCodeGenerator().createIndexCode(ui5Library, rootModuleName, initialViewExt); // } // } // // Path: src/com/atsebak/ui5/autogeneration/UI5View.java // @NoArgsConstructor // public abstract class UI5View { // @Getter // private final CodeGenerator codeGenerator = new CodeGenerator(); // @Getter // private String extension; // // public UI5View(@NotNull String extension) { // this.extension = extension; // } // // /** // * Given the application type and the module path for generation // * @param appType // * @param controllerPath // * @return // */ // public String generateCode(AppType appType, String controllerPath) { // return codeGenerator.createViewCode(appType, controllerPath, extension); // } // } // // Path: src/com/atsebak/ui5/locale/UI5Bundle.java // public final class UI5Bundle { // // @NonNls // private static final String BUNDLE = "com.atsebak.ui5.locale.UI5Bundle"; // private static Reference<ResourceBundle> bundleReference; // // /** // * Private Constructor // */ // private UI5Bundle() { // } // // /** // * @param key // * @param params // * @return // */ // public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { // return BundleBase.message(getBundle(), key, params); // } // // /** // * @return // */ // private static ResourceBundle getBundle() { // ResourceBundle bundle = dereference(bundleReference); // if (bundle == null) { // bundle = ResourceBundle.getBundle(BUNDLE); // bundleReference = new SoftReference<ResourceBundle>(bundle); // } // return bundle; // } // // /** // * @param key The Key // * @return The Localized Text // */ // public static String getString(@PropertyKey(resourceBundle = BUNDLE) final String key) { // return getBundle().getString(key); // } // } // // Path: src/com/atsebak/ui5/util/Writer.java // public final class Writer { // // /** // * Private constructor // */ // private Writer() { // // } // /** // * Writes content to a specific file // * @param file // * @param content // * @throws IOException // */ // public static void writeToFile(@NotNull File file,@NotNull String content) throws IOException { // BufferedWriter bw = new BufferedWriter(new FileWriter(file)); // bw.write(content); // bw.close(); // } // } // Path: src/com/atsebak/ui5/projectbuilder/UI5ProjectTemplateGenerator.java import com.atsebak.ui5.AppType; import com.atsebak.ui5.FileType; import com.atsebak.ui5.autogeneration.Controller; import com.atsebak.ui5.autogeneration.Index; import com.atsebak.ui5.autogeneration.UI5View; import com.atsebak.ui5.locale.UI5Bundle; import com.atsebak.ui5.util.*; import com.atsebak.ui5.util.Writer; import com.intellij.ide.util.projectWizard.WebProjectTemplate; import com.intellij.openapi.module.Module; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VirtualFile; import lombok.Data; import lombok.SneakyThrows; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.io.*; package com.atsebak.ui5.projectbuilder; /** * This is for the sub template of the project. * Once the finished but is click generateProject method is called and runs a separate process */ public class UI5ProjectTemplateGenerator extends WebProjectTemplate<UI5ProjectTemplateGenerator.UI5ProjectSettings> { private static final String UI5_RESOURCE_PATH = "/ui5/"; private static final String RESOURCE_PATH = UI5_RESOURCE_PATH + "ui5/resources.zip"; @Nls @NotNull @Override public String getName() { return UI5Bundle.getString("app"); } @Override public String getDescription() { return UI5Bundle.getString("app.description"); } @Override public void generateProject(@NotNull final Project project, @NotNull final VirtualFile virtualFile, @NotNull final UI5ProjectSettings settings, @NotNull Module module) { if (settings.getLibrary() == null) { settings.setLibrary(AppType.DESKTOP); } final Index index = new Index();
final UI5View view = settings.getView();
asebak/ui5-intellij-plugin
src/com/atsebak/ui5/autogeneration/CodeGenerator.java
// Path: src/com/atsebak/ui5/AppType.java // public enum AppType { // DESKTOP, // MOBILE // }
import com.atsebak.ui5.AppType; import org.jetbrains.annotations.NotNull; import java.util.HashMap;
package com.atsebak.ui5.autogeneration; public final class CodeGenerator { /** * Controller.js code * * @param root * @return */ public String createControllerCode(@NotNull final String root) { return createTemplate("templates/controller.js.ftl", new HashMap<String, Object>() {{ put("root", root); }}); } /** * Index.html code * * @param appType * @param rootModuleName * @param intialViewExt * @return */
// Path: src/com/atsebak/ui5/AppType.java // public enum AppType { // DESKTOP, // MOBILE // } // Path: src/com/atsebak/ui5/autogeneration/CodeGenerator.java import com.atsebak.ui5.AppType; import org.jetbrains.annotations.NotNull; import java.util.HashMap; package com.atsebak.ui5.autogeneration; public final class CodeGenerator { /** * Controller.js code * * @param root * @return */ public String createControllerCode(@NotNull final String root) { return createTemplate("templates/controller.js.ftl", new HashMap<String, Object>() {{ put("root", root); }}); } /** * Index.html code * * @param appType * @param rootModuleName * @param intialViewExt * @return */
public String createIndexCode(@NotNull AppType appType, @NotNull final String rootModuleName, @NotNull final String intialViewExt) {
asebak/ui5-intellij-plugin
src/com/atsebak/ui5/util/UI5FileBuilder.java
// Path: src/com/atsebak/ui5/FileType.java // public enum FileType { // JS, // XML, // HTML, // JSON, // PROPERTIES // }
import com.atsebak.ui5.FileType; import com.atsebak.ui5.autogeneration.*; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleUtilCore; import com.intellij.psi.PsiDirectory; import org.jetbrains.annotations.NotNull; import java.io.File; import java.util.regex.Pattern;
String filePath = new File(psiDirectory.getVirtualFile().getPath()).getPath(); assert projectPath != null; projectDircs = projectPath.split(Pattern.quote(File.separator)); fileDircs = filePath.split(Pattern.quote(File.separator)); for (int i = 0; i < projectDircs.length; i++) { if (projectDircs[i].equals(fileDircs[i])) { fileDircs[i] = ""; } } String codePath = ""; for (int i = 0; i < fileDircs.length; i++) { if (!fileDircs[i].isEmpty()) { codePath += fileDircs[i]; if (i != fileDircs.length - 1) { codePath += "."; } } } return codePath; } return ""; } /** * Get the interface implementation * * @param type * @return */
// Path: src/com/atsebak/ui5/FileType.java // public enum FileType { // JS, // XML, // HTML, // JSON, // PROPERTIES // } // Path: src/com/atsebak/ui5/util/UI5FileBuilder.java import com.atsebak.ui5.FileType; import com.atsebak.ui5.autogeneration.*; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleUtilCore; import com.intellij.psi.PsiDirectory; import org.jetbrains.annotations.NotNull; import java.io.File; import java.util.regex.Pattern; String filePath = new File(psiDirectory.getVirtualFile().getPath()).getPath(); assert projectPath != null; projectDircs = projectPath.split(Pattern.quote(File.separator)); fileDircs = filePath.split(Pattern.quote(File.separator)); for (int i = 0; i < projectDircs.length; i++) { if (projectDircs[i].equals(fileDircs[i])) { fileDircs[i] = ""; } } String codePath = ""; for (int i = 0; i < fileDircs.length; i++) { if (!fileDircs[i].isEmpty()) { codePath += fileDircs[i]; if (i != fileDircs.length - 1) { codePath += "."; } } } return codePath; } return ""; } /** * Get the interface implementation * * @param type * @return */
public static UI5View getViewImplementation(@NotNull FileType type) {
asebak/ui5-intellij-plugin
src/com/atsebak/ui5/actions/search/UI5ApiSearch.java
// Path: src/com/atsebak/ui5/locale/UI5Bundle.java // public final class UI5Bundle { // // @NonNls // private static final String BUNDLE = "com.atsebak.ui5.locale.UI5Bundle"; // private static Reference<ResourceBundle> bundleReference; // // /** // * Private Constructor // */ // private UI5Bundle() { // } // // /** // * @param key // * @param params // * @return // */ // public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { // return BundleBase.message(getBundle(), key, params); // } // // /** // * @return // */ // private static ResourceBundle getBundle() { // ResourceBundle bundle = dereference(bundleReference); // if (bundle == null) { // bundle = ResourceBundle.getBundle(BUNDLE); // bundleReference = new SoftReference<ResourceBundle>(bundle); // } // return bundle; // } // // /** // * @param key The Key // * @return The Localized Text // */ // public static String getString(@PropertyKey(resourceBundle = BUNDLE) final String key) { // return getBundle().getString(key); // } // }
import com.atsebak.ui5.locale.UI5Bundle; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; import org.apache.commons.lang.StringUtils; import org.jetbrains.annotations.NotNull;
package com.atsebak.ui5.actions.search; public class UI5ApiSearch extends AnAction { /** * Action performed from Intellij * @param anActionEvent */ @Override public void actionPerformed(AnActionEvent anActionEvent) { final DataContext dataContext = anActionEvent.getDataContext(); final Project project = CommonDataKeys.PROJECT.getData(dataContext); Editor editor = CommonDataKeys.EDITOR.getData(dataContext); if (project == null || editor == null) { return; } execute(editor, project); } /** * Executes the action * @param editor * @param project */ private void execute(@NotNull Editor editor, @NotNull Project project) { String selectedTerm = SearchTermFinder.builder() .editor(editor) .build() .getSearchTerm(); if (StringUtils.isNotBlank(selectedTerm)) { UI5ApiSearchDialog.builder().project(project).build().show(selectedTerm); } else {
// Path: src/com/atsebak/ui5/locale/UI5Bundle.java // public final class UI5Bundle { // // @NonNls // private static final String BUNDLE = "com.atsebak.ui5.locale.UI5Bundle"; // private static Reference<ResourceBundle> bundleReference; // // /** // * Private Constructor // */ // private UI5Bundle() { // } // // /** // * @param key // * @param params // * @return // */ // public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { // return BundleBase.message(getBundle(), key, params); // } // // /** // * @return // */ // private static ResourceBundle getBundle() { // ResourceBundle bundle = dereference(bundleReference); // if (bundle == null) { // bundle = ResourceBundle.getBundle(BUNDLE); // bundleReference = new SoftReference<ResourceBundle>(bundle); // } // return bundle; // } // // /** // * @param key The Key // * @return The Localized Text // */ // public static String getString(@PropertyKey(resourceBundle = BUNDLE) final String key) { // return getBundle().getString(key); // } // } // Path: src/com/atsebak/ui5/actions/search/UI5ApiSearch.java import com.atsebak.ui5.locale.UI5Bundle; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; import org.apache.commons.lang.StringUtils; import org.jetbrains.annotations.NotNull; package com.atsebak.ui5.actions.search; public class UI5ApiSearch extends AnAction { /** * Action performed from Intellij * @param anActionEvent */ @Override public void actionPerformed(AnActionEvent anActionEvent) { final DataContext dataContext = anActionEvent.getDataContext(); final Project project = CommonDataKeys.PROJECT.getData(dataContext); Editor editor = CommonDataKeys.EDITOR.getData(dataContext); if (project == null || editor == null) { return; } execute(editor, project); } /** * Executes the action * @param editor * @param project */ private void execute(@NotNull Editor editor, @NotNull Project project) { String selectedTerm = SearchTermFinder.builder() .editor(editor) .build() .getSearchTerm(); if (StringUtils.isNotBlank(selectedTerm)) { UI5ApiSearchDialog.builder().project(project).build().show(selectedTerm); } else {
Messages.showErrorDialog(project, UI5Bundle.getString("api.search.errormsg"), UI5Bundle.getString("error"));
asebak/ui5-intellij-plugin
test/com/atsebak/ui5/autogeneration/XMLViewTest.java
// Path: src/com/atsebak/ui5/AppType.java // public enum AppType { // DESKTOP, // MOBILE // }
import com.atsebak.ui5.AppType; import org.junit.Test; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat;
package com.atsebak.ui5.autogeneration; public class XMLViewTest { @Test public void testGetExtension() { UI5View view = new XMLView(); assertEquals(view.getExtension(), "xml"); } @Test public void testAutogenerateCodeForDesktop() { UI5View view = new XMLView();
// Path: src/com/atsebak/ui5/AppType.java // public enum AppType { // DESKTOP, // MOBILE // } // Path: test/com/atsebak/ui5/autogeneration/XMLViewTest.java import com.atsebak.ui5.AppType; import org.junit.Test; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; package com.atsebak.ui5.autogeneration; public class XMLViewTest { @Test public void testGetExtension() { UI5View view = new XMLView(); assertEquals(view.getExtension(), "xml"); } @Test public void testAutogenerateCodeForDesktop() { UI5View view = new XMLView();
String s = view.generateCode(AppType.DESKTOP, "com.atsebak");
asebak/ui5-intellij-plugin
test/com/atsebak/ui5/autogeneration/HTMLViewTest.java
// Path: src/com/atsebak/ui5/AppType.java // public enum AppType { // DESKTOP, // MOBILE // }
import com.atsebak.ui5.AppType; import org.junit.Test; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat;
package com.atsebak.ui5.autogeneration; public class HTMLViewTest { @Test public void testGetExtension() { UI5View htmlView = new HTMLView(); assertEquals(htmlView.getExtension(), "html"); } @Test public void testAutogenerateCodeForDesktop() { UI5View htmlView = new HTMLView();
// Path: src/com/atsebak/ui5/AppType.java // public enum AppType { // DESKTOP, // MOBILE // } // Path: test/com/atsebak/ui5/autogeneration/HTMLViewTest.java import com.atsebak.ui5.AppType; import org.junit.Test; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; package com.atsebak.ui5.autogeneration; public class HTMLViewTest { @Test public void testGetExtension() { UI5View htmlView = new HTMLView(); assertEquals(htmlView.getExtension(), "html"); } @Test public void testAutogenerateCodeForDesktop() { UI5View htmlView = new HTMLView();
String s = htmlView.generateCode(AppType.DESKTOP, "com.atsebak");
asebak/ui5-intellij-plugin
src/com/atsebak/ui5/actions/search/UI5ApiSearchDialog.java
// Path: src/com/atsebak/ui5/locale/UI5Bundle.java // public final class UI5Bundle { // // @NonNls // private static final String BUNDLE = "com.atsebak.ui5.locale.UI5Bundle"; // private static Reference<ResourceBundle> bundleReference; // // /** // * Private Constructor // */ // private UI5Bundle() { // } // // /** // * @param key // * @param params // * @return // */ // public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { // return BundleBase.message(getBundle(), key, params); // } // // /** // * @return // */ // private static ResourceBundle getBundle() { // ResourceBundle bundle = dereference(bundleReference); // if (bundle == null) { // bundle = ResourceBundle.getBundle(BUNDLE); // bundleReference = new SoftReference<ResourceBundle>(bundle); // } // return bundle; // } // // /** // * @param key The Key // * @return The Localized Text // */ // public static String getString(@PropertyKey(resourceBundle = BUNDLE) final String key) { // return getBundle().getString(key); // } // }
import com.atsebak.ui5.locale.UI5Bundle; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogBuilder; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.Messages; import lombok.Builder; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.net.URL;
package com.atsebak.ui5.actions.search; @Builder public class UI5ApiSearchDialog { private final static String API_PAGE = "https://sapui5.netweaver.ondemand.com/sdk/search.html?q="; private Project project; /** * Show the search dialog * @param searchTerm */ public void show(@Nullable final String searchTerm) { final JTextField searchTextField = new JTextField(searchTerm); JPanel panel = new JPanel(new BorderLayout());
// Path: src/com/atsebak/ui5/locale/UI5Bundle.java // public final class UI5Bundle { // // @NonNls // private static final String BUNDLE = "com.atsebak.ui5.locale.UI5Bundle"; // private static Reference<ResourceBundle> bundleReference; // // /** // * Private Constructor // */ // private UI5Bundle() { // } // // /** // * @param key // * @param params // * @return // */ // public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { // return BundleBase.message(getBundle(), key, params); // } // // /** // * @return // */ // private static ResourceBundle getBundle() { // ResourceBundle bundle = dereference(bundleReference); // if (bundle == null) { // bundle = ResourceBundle.getBundle(BUNDLE); // bundleReference = new SoftReference<ResourceBundle>(bundle); // } // return bundle; // } // // /** // * @param key The Key // * @return The Localized Text // */ // public static String getString(@PropertyKey(resourceBundle = BUNDLE) final String key) { // return getBundle().getString(key); // } // } // Path: src/com/atsebak/ui5/actions/search/UI5ApiSearchDialog.java import com.atsebak.ui5.locale.UI5Bundle; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogBuilder; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.Messages; import lombok.Builder; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.net.URL; package com.atsebak.ui5.actions.search; @Builder public class UI5ApiSearchDialog { private final static String API_PAGE = "https://sapui5.netweaver.ondemand.com/sdk/search.html?q="; private Project project; /** * Show the search dialog * @param searchTerm */ public void show(@Nullable final String searchTerm) { final JTextField searchTextField = new JTextField(searchTerm); JPanel panel = new JPanel(new BorderLayout());
panel.add(new JLabel(UI5Bundle.getString("api.searchterm")), BorderLayout.WEST);
asebak/ui5-intellij-plugin
test/com/atsebak/ui5/projectbuilder/ProjectPeerTest.java
// Path: src/com/atsebak/ui5/autogeneration/JSView.java // public class JSView extends UI5View { // public JSView() { // super("js"); // } // }
import com.atsebak.ui5.autogeneration.JSView; import org.junit.Test; import static org.hamcrest.core.IsInstanceOf.instanceOf; import static org.junit.Assert.assertThat;
package com.atsebak.ui5.projectbuilder; public class ProjectPeerTest { @Test public void testGetSettings() { ProjectPeer projectPeer = new ProjectPeer(); UI5ProjectTemplateGenerator.UI5ProjectSettings settings = projectPeer.getSettings();
// Path: src/com/atsebak/ui5/autogeneration/JSView.java // public class JSView extends UI5View { // public JSView() { // super("js"); // } // } // Path: test/com/atsebak/ui5/projectbuilder/ProjectPeerTest.java import com.atsebak.ui5.autogeneration.JSView; import org.junit.Test; import static org.hamcrest.core.IsInstanceOf.instanceOf; import static org.junit.Assert.assertThat; package com.atsebak.ui5.projectbuilder; public class ProjectPeerTest { @Test public void testGetSettings() { ProjectPeer projectPeer = new ProjectPeer(); UI5ProjectTemplateGenerator.UI5ProjectSettings settings = projectPeer.getSettings();
assertThat(settings.getView(), instanceOf(JSView.class));
asebak/ui5-intellij-plugin
test/com/atsebak/ui5/util/UI5FileBuilderTest.java
// Path: src/com/atsebak/ui5/FileType.java // public enum FileType { // JS, // XML, // HTML, // JSON, // PROPERTIES // }
import com.atsebak.ui5.FileType; import com.atsebak.ui5.autogeneration.*; import org.junit.Test; import static org.hamcrest.core.IsInstanceOf.instanceOf; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat;
package com.atsebak.ui5.util; public class UI5FileBuilderTest { @Test public void testDepedencyImplementation() {
// Path: src/com/atsebak/ui5/FileType.java // public enum FileType { // JS, // XML, // HTML, // JSON, // PROPERTIES // } // Path: test/com/atsebak/ui5/util/UI5FileBuilderTest.java import com.atsebak.ui5.FileType; import com.atsebak.ui5.autogeneration.*; import org.junit.Test; import static org.hamcrest.core.IsInstanceOf.instanceOf; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; package com.atsebak.ui5.util; public class UI5FileBuilderTest { @Test public void testDepedencyImplementation() {
UI5View viewImplementation = UI5FileBuilder.getViewImplementation(FileType.JS);
asebak/ui5-intellij-plugin
src/com/atsebak/ui5/util/ProjectHelper.java
// Path: src/com/atsebak/ui5/runner/UI5RunConfiguration.java // @Getter // public class UI5RunConfiguration extends RunConfigurationBase { // private UI5RunnerParameters runnerParameters = new UI5RunnerParameters(); // // protected UI5RunConfiguration(@NotNull Project project, @NotNull ConfigurationFactory factory, @NotNull String name) { // super(project, factory, name); // } // // @NotNull // @Override // public SettingsEditor<? extends RunConfiguration> getConfigurationEditor() { // return new UI5RunConfigurationEditor(); // } // // @Override // public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException { // return EmptyRunProfileState.INSTANCE; // } // // @Override // public void checkConfiguration() throws RuntimeConfigurationException { // // } // // } // // Path: src/com/atsebak/ui5/runner/UI5RunConfigurationType.java // @Getter // public class UI5RunConfigurationType implements ConfigurationType { // private ConfigurationFactory factory; // // public UI5RunConfigurationType() { // factory = new ConfigurationFactory(this) { // public RunConfiguration createTemplateConfiguration(Project project) { // return new UI5RunConfiguration(project, this, "OpenUI5"); // } // }; // } // // @NotNull // public static UI5RunConfigurationType getInstance() { // return ConfigurationTypeUtil.findConfigurationType(UI5RunConfigurationType.class); // } // // @Override // public String getDisplayName() { // return "Open UI5"; // } // // @Override // public String getConfigurationTypeDescription() { // return UI5Bundle.getString("run.app"); // } // // @Override // public Icon getIcon() { // return UI5Icons.getIcon(); // } // // @NotNull // public String getId() { // return getConfigurationTypeDescription(); // } // // @Override // public ConfigurationFactory[] getConfigurationFactories() { // return new ConfigurationFactory[]{factory}; // } // }
import com.atsebak.ui5.runner.UI5RunConfiguration; import com.atsebak.ui5.runner.UI5RunConfigurationType; import com.intellij.execution.RunManager; import com.intellij.execution.RunnerAndConfigurationSettings; import com.intellij.ide.browsers.WebBrowserManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.newvfs.RefreshQueue; import org.jetbrains.annotations.NotNull; import java.io.File; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator;
package com.atsebak.ui5.util; public final class ProjectHelper { private ProjectHelper() { } /** * Adds a run configuration to project * @param project */ public static void addRunConfiguration(@NotNull final Project project) { final Runnable r = new Runnable() { @Override public void run() { final RunManager runManager = RunManager.getInstance(project); final RunnerAndConfigurationSettings settings = runManager.
// Path: src/com/atsebak/ui5/runner/UI5RunConfiguration.java // @Getter // public class UI5RunConfiguration extends RunConfigurationBase { // private UI5RunnerParameters runnerParameters = new UI5RunnerParameters(); // // protected UI5RunConfiguration(@NotNull Project project, @NotNull ConfigurationFactory factory, @NotNull String name) { // super(project, factory, name); // } // // @NotNull // @Override // public SettingsEditor<? extends RunConfiguration> getConfigurationEditor() { // return new UI5RunConfigurationEditor(); // } // // @Override // public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException { // return EmptyRunProfileState.INSTANCE; // } // // @Override // public void checkConfiguration() throws RuntimeConfigurationException { // // } // // } // // Path: src/com/atsebak/ui5/runner/UI5RunConfigurationType.java // @Getter // public class UI5RunConfigurationType implements ConfigurationType { // private ConfigurationFactory factory; // // public UI5RunConfigurationType() { // factory = new ConfigurationFactory(this) { // public RunConfiguration createTemplateConfiguration(Project project) { // return new UI5RunConfiguration(project, this, "OpenUI5"); // } // }; // } // // @NotNull // public static UI5RunConfigurationType getInstance() { // return ConfigurationTypeUtil.findConfigurationType(UI5RunConfigurationType.class); // } // // @Override // public String getDisplayName() { // return "Open UI5"; // } // // @Override // public String getConfigurationTypeDescription() { // return UI5Bundle.getString("run.app"); // } // // @Override // public Icon getIcon() { // return UI5Icons.getIcon(); // } // // @NotNull // public String getId() { // return getConfigurationTypeDescription(); // } // // @Override // public ConfigurationFactory[] getConfigurationFactories() { // return new ConfigurationFactory[]{factory}; // } // } // Path: src/com/atsebak/ui5/util/ProjectHelper.java import com.atsebak.ui5.runner.UI5RunConfiguration; import com.atsebak.ui5.runner.UI5RunConfigurationType; import com.intellij.execution.RunManager; import com.intellij.execution.RunnerAndConfigurationSettings; import com.intellij.ide.browsers.WebBrowserManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.newvfs.RefreshQueue; import org.jetbrains.annotations.NotNull; import java.io.File; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; package com.atsebak.ui5.util; public final class ProjectHelper { private ProjectHelper() { } /** * Adds a run configuration to project * @param project */ public static void addRunConfiguration(@NotNull final Project project) { final Runnable r = new Runnable() { @Override public void run() { final RunManager runManager = RunManager.getInstance(project); final RunnerAndConfigurationSettings settings = runManager.
createRunConfiguration(project.getName(), UI5RunConfigurationType.getInstance().getFactory());
asebak/ui5-intellij-plugin
src/com/atsebak/ui5/util/ProjectHelper.java
// Path: src/com/atsebak/ui5/runner/UI5RunConfiguration.java // @Getter // public class UI5RunConfiguration extends RunConfigurationBase { // private UI5RunnerParameters runnerParameters = new UI5RunnerParameters(); // // protected UI5RunConfiguration(@NotNull Project project, @NotNull ConfigurationFactory factory, @NotNull String name) { // super(project, factory, name); // } // // @NotNull // @Override // public SettingsEditor<? extends RunConfiguration> getConfigurationEditor() { // return new UI5RunConfigurationEditor(); // } // // @Override // public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException { // return EmptyRunProfileState.INSTANCE; // } // // @Override // public void checkConfiguration() throws RuntimeConfigurationException { // // } // // } // // Path: src/com/atsebak/ui5/runner/UI5RunConfigurationType.java // @Getter // public class UI5RunConfigurationType implements ConfigurationType { // private ConfigurationFactory factory; // // public UI5RunConfigurationType() { // factory = new ConfigurationFactory(this) { // public RunConfiguration createTemplateConfiguration(Project project) { // return new UI5RunConfiguration(project, this, "OpenUI5"); // } // }; // } // // @NotNull // public static UI5RunConfigurationType getInstance() { // return ConfigurationTypeUtil.findConfigurationType(UI5RunConfigurationType.class); // } // // @Override // public String getDisplayName() { // return "Open UI5"; // } // // @Override // public String getConfigurationTypeDescription() { // return UI5Bundle.getString("run.app"); // } // // @Override // public Icon getIcon() { // return UI5Icons.getIcon(); // } // // @NotNull // public String getId() { // return getConfigurationTypeDescription(); // } // // @Override // public ConfigurationFactory[] getConfigurationFactories() { // return new ConfigurationFactory[]{factory}; // } // }
import com.atsebak.ui5.runner.UI5RunConfiguration; import com.atsebak.ui5.runner.UI5RunConfigurationType; import com.intellij.execution.RunManager; import com.intellij.execution.RunnerAndConfigurationSettings; import com.intellij.ide.browsers.WebBrowserManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.newvfs.RefreshQueue; import org.jetbrains.annotations.NotNull; import java.io.File; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator;
package com.atsebak.ui5.util; public final class ProjectHelper { private ProjectHelper() { } /** * Adds a run configuration to project * @param project */ public static void addRunConfiguration(@NotNull final Project project) { final Runnable r = new Runnable() { @Override public void run() { final RunManager runManager = RunManager.getInstance(project); final RunnerAndConfigurationSettings settings = runManager. createRunConfiguration(project.getName(), UI5RunConfigurationType.getInstance().getFactory());
// Path: src/com/atsebak/ui5/runner/UI5RunConfiguration.java // @Getter // public class UI5RunConfiguration extends RunConfigurationBase { // private UI5RunnerParameters runnerParameters = new UI5RunnerParameters(); // // protected UI5RunConfiguration(@NotNull Project project, @NotNull ConfigurationFactory factory, @NotNull String name) { // super(project, factory, name); // } // // @NotNull // @Override // public SettingsEditor<? extends RunConfiguration> getConfigurationEditor() { // return new UI5RunConfigurationEditor(); // } // // @Override // public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException { // return EmptyRunProfileState.INSTANCE; // } // // @Override // public void checkConfiguration() throws RuntimeConfigurationException { // // } // // } // // Path: src/com/atsebak/ui5/runner/UI5RunConfigurationType.java // @Getter // public class UI5RunConfigurationType implements ConfigurationType { // private ConfigurationFactory factory; // // public UI5RunConfigurationType() { // factory = new ConfigurationFactory(this) { // public RunConfiguration createTemplateConfiguration(Project project) { // return new UI5RunConfiguration(project, this, "OpenUI5"); // } // }; // } // // @NotNull // public static UI5RunConfigurationType getInstance() { // return ConfigurationTypeUtil.findConfigurationType(UI5RunConfigurationType.class); // } // // @Override // public String getDisplayName() { // return "Open UI5"; // } // // @Override // public String getConfigurationTypeDescription() { // return UI5Bundle.getString("run.app"); // } // // @Override // public Icon getIcon() { // return UI5Icons.getIcon(); // } // // @NotNull // public String getId() { // return getConfigurationTypeDescription(); // } // // @Override // public ConfigurationFactory[] getConfigurationFactories() { // return new ConfigurationFactory[]{factory}; // } // } // Path: src/com/atsebak/ui5/util/ProjectHelper.java import com.atsebak.ui5.runner.UI5RunConfiguration; import com.atsebak.ui5.runner.UI5RunConfigurationType; import com.intellij.execution.RunManager; import com.intellij.execution.RunnerAndConfigurationSettings; import com.intellij.ide.browsers.WebBrowserManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.newvfs.RefreshQueue; import org.jetbrains.annotations.NotNull; import java.io.File; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; package com.atsebak.ui5.util; public final class ProjectHelper { private ProjectHelper() { } /** * Adds a run configuration to project * @param project */ public static void addRunConfiguration(@NotNull final Project project) { final Runnable r = new Runnable() { @Override public void run() { final RunManager runManager = RunManager.getInstance(project); final RunnerAndConfigurationSettings settings = runManager. createRunConfiguration(project.getName(), UI5RunConfigurationType.getInstance().getFactory());
final UI5RunConfiguration configuration = (UI5RunConfiguration) settings.getConfiguration();
asebak/ui5-intellij-plugin
src/com/atsebak/ui5/runner/UI5RunConfigurationType.java
// Path: src/com/atsebak/ui5/locale/UI5Bundle.java // public final class UI5Bundle { // // @NonNls // private static final String BUNDLE = "com.atsebak.ui5.locale.UI5Bundle"; // private static Reference<ResourceBundle> bundleReference; // // /** // * Private Constructor // */ // private UI5Bundle() { // } // // /** // * @param key // * @param params // * @return // */ // public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { // return BundleBase.message(getBundle(), key, params); // } // // /** // * @return // */ // private static ResourceBundle getBundle() { // ResourceBundle bundle = dereference(bundleReference); // if (bundle == null) { // bundle = ResourceBundle.getBundle(BUNDLE); // bundleReference = new SoftReference<ResourceBundle>(bundle); // } // return bundle; // } // // /** // * @param key The Key // * @return The Localized Text // */ // public static String getString(@PropertyKey(resourceBundle = BUNDLE) final String key) { // return getBundle().getString(key); // } // } // // Path: src/com/atsebak/ui5/util/UI5Icons.java // public final class UI5Icons { // /** // * Private constructor // */ // private UI5Icons() { // // } // /** // * Get the Main UI5 Icon // * @return // */ // public static Icon getIcon(){ // return IconLoader.getIcon("/ui5.png", UI5Icons.class); // } // }
import com.atsebak.ui5.locale.UI5Bundle; import com.atsebak.ui5.util.UI5Icons; import com.intellij.execution.configurations.ConfigurationFactory; import com.intellij.execution.configurations.ConfigurationType; import com.intellij.execution.configurations.ConfigurationTypeUtil; import com.intellij.execution.configurations.RunConfiguration; import com.intellij.openapi.project.Project; import lombok.Getter; import org.jetbrains.annotations.NotNull; import javax.swing.*;
package com.atsebak.ui5.runner; @Getter public class UI5RunConfigurationType implements ConfigurationType { private ConfigurationFactory factory; public UI5RunConfigurationType() { factory = new ConfigurationFactory(this) { public RunConfiguration createTemplateConfiguration(Project project) { return new UI5RunConfiguration(project, this, "OpenUI5"); } }; } @NotNull public static UI5RunConfigurationType getInstance() { return ConfigurationTypeUtil.findConfigurationType(UI5RunConfigurationType.class); } @Override public String getDisplayName() { return "Open UI5"; } @Override public String getConfigurationTypeDescription() {
// Path: src/com/atsebak/ui5/locale/UI5Bundle.java // public final class UI5Bundle { // // @NonNls // private static final String BUNDLE = "com.atsebak.ui5.locale.UI5Bundle"; // private static Reference<ResourceBundle> bundleReference; // // /** // * Private Constructor // */ // private UI5Bundle() { // } // // /** // * @param key // * @param params // * @return // */ // public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { // return BundleBase.message(getBundle(), key, params); // } // // /** // * @return // */ // private static ResourceBundle getBundle() { // ResourceBundle bundle = dereference(bundleReference); // if (bundle == null) { // bundle = ResourceBundle.getBundle(BUNDLE); // bundleReference = new SoftReference<ResourceBundle>(bundle); // } // return bundle; // } // // /** // * @param key The Key // * @return The Localized Text // */ // public static String getString(@PropertyKey(resourceBundle = BUNDLE) final String key) { // return getBundle().getString(key); // } // } // // Path: src/com/atsebak/ui5/util/UI5Icons.java // public final class UI5Icons { // /** // * Private constructor // */ // private UI5Icons() { // // } // /** // * Get the Main UI5 Icon // * @return // */ // public static Icon getIcon(){ // return IconLoader.getIcon("/ui5.png", UI5Icons.class); // } // } // Path: src/com/atsebak/ui5/runner/UI5RunConfigurationType.java import com.atsebak.ui5.locale.UI5Bundle; import com.atsebak.ui5.util.UI5Icons; import com.intellij.execution.configurations.ConfigurationFactory; import com.intellij.execution.configurations.ConfigurationType; import com.intellij.execution.configurations.ConfigurationTypeUtil; import com.intellij.execution.configurations.RunConfiguration; import com.intellij.openapi.project.Project; import lombok.Getter; import org.jetbrains.annotations.NotNull; import javax.swing.*; package com.atsebak.ui5.runner; @Getter public class UI5RunConfigurationType implements ConfigurationType { private ConfigurationFactory factory; public UI5RunConfigurationType() { factory = new ConfigurationFactory(this) { public RunConfiguration createTemplateConfiguration(Project project) { return new UI5RunConfiguration(project, this, "OpenUI5"); } }; } @NotNull public static UI5RunConfigurationType getInstance() { return ConfigurationTypeUtil.findConfigurationType(UI5RunConfigurationType.class); } @Override public String getDisplayName() { return "Open UI5"; } @Override public String getConfigurationTypeDescription() {
return UI5Bundle.getString("run.app");
asebak/ui5-intellij-plugin
src/com/atsebak/ui5/runner/UI5RunConfigurationType.java
// Path: src/com/atsebak/ui5/locale/UI5Bundle.java // public final class UI5Bundle { // // @NonNls // private static final String BUNDLE = "com.atsebak.ui5.locale.UI5Bundle"; // private static Reference<ResourceBundle> bundleReference; // // /** // * Private Constructor // */ // private UI5Bundle() { // } // // /** // * @param key // * @param params // * @return // */ // public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { // return BundleBase.message(getBundle(), key, params); // } // // /** // * @return // */ // private static ResourceBundle getBundle() { // ResourceBundle bundle = dereference(bundleReference); // if (bundle == null) { // bundle = ResourceBundle.getBundle(BUNDLE); // bundleReference = new SoftReference<ResourceBundle>(bundle); // } // return bundle; // } // // /** // * @param key The Key // * @return The Localized Text // */ // public static String getString(@PropertyKey(resourceBundle = BUNDLE) final String key) { // return getBundle().getString(key); // } // } // // Path: src/com/atsebak/ui5/util/UI5Icons.java // public final class UI5Icons { // /** // * Private constructor // */ // private UI5Icons() { // // } // /** // * Get the Main UI5 Icon // * @return // */ // public static Icon getIcon(){ // return IconLoader.getIcon("/ui5.png", UI5Icons.class); // } // }
import com.atsebak.ui5.locale.UI5Bundle; import com.atsebak.ui5.util.UI5Icons; import com.intellij.execution.configurations.ConfigurationFactory; import com.intellij.execution.configurations.ConfigurationType; import com.intellij.execution.configurations.ConfigurationTypeUtil; import com.intellij.execution.configurations.RunConfiguration; import com.intellij.openapi.project.Project; import lombok.Getter; import org.jetbrains.annotations.NotNull; import javax.swing.*;
package com.atsebak.ui5.runner; @Getter public class UI5RunConfigurationType implements ConfigurationType { private ConfigurationFactory factory; public UI5RunConfigurationType() { factory = new ConfigurationFactory(this) { public RunConfiguration createTemplateConfiguration(Project project) { return new UI5RunConfiguration(project, this, "OpenUI5"); } }; } @NotNull public static UI5RunConfigurationType getInstance() { return ConfigurationTypeUtil.findConfigurationType(UI5RunConfigurationType.class); } @Override public String getDisplayName() { return "Open UI5"; } @Override public String getConfigurationTypeDescription() { return UI5Bundle.getString("run.app"); } @Override public Icon getIcon() {
// Path: src/com/atsebak/ui5/locale/UI5Bundle.java // public final class UI5Bundle { // // @NonNls // private static final String BUNDLE = "com.atsebak.ui5.locale.UI5Bundle"; // private static Reference<ResourceBundle> bundleReference; // // /** // * Private Constructor // */ // private UI5Bundle() { // } // // /** // * @param key // * @param params // * @return // */ // public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { // return BundleBase.message(getBundle(), key, params); // } // // /** // * @return // */ // private static ResourceBundle getBundle() { // ResourceBundle bundle = dereference(bundleReference); // if (bundle == null) { // bundle = ResourceBundle.getBundle(BUNDLE); // bundleReference = new SoftReference<ResourceBundle>(bundle); // } // return bundle; // } // // /** // * @param key The Key // * @return The Localized Text // */ // public static String getString(@PropertyKey(resourceBundle = BUNDLE) final String key) { // return getBundle().getString(key); // } // } // // Path: src/com/atsebak/ui5/util/UI5Icons.java // public final class UI5Icons { // /** // * Private constructor // */ // private UI5Icons() { // // } // /** // * Get the Main UI5 Icon // * @return // */ // public static Icon getIcon(){ // return IconLoader.getIcon("/ui5.png", UI5Icons.class); // } // } // Path: src/com/atsebak/ui5/runner/UI5RunConfigurationType.java import com.atsebak.ui5.locale.UI5Bundle; import com.atsebak.ui5.util.UI5Icons; import com.intellij.execution.configurations.ConfigurationFactory; import com.intellij.execution.configurations.ConfigurationType; import com.intellij.execution.configurations.ConfigurationTypeUtil; import com.intellij.execution.configurations.RunConfiguration; import com.intellij.openapi.project.Project; import lombok.Getter; import org.jetbrains.annotations.NotNull; import javax.swing.*; package com.atsebak.ui5.runner; @Getter public class UI5RunConfigurationType implements ConfigurationType { private ConfigurationFactory factory; public UI5RunConfigurationType() { factory = new ConfigurationFactory(this) { public RunConfiguration createTemplateConfiguration(Project project) { return new UI5RunConfiguration(project, this, "OpenUI5"); } }; } @NotNull public static UI5RunConfigurationType getInstance() { return ConfigurationTypeUtil.findConfigurationType(UI5RunConfigurationType.class); } @Override public String getDisplayName() { return "Open UI5"; } @Override public String getConfigurationTypeDescription() { return UI5Bundle.getString("run.app"); } @Override public Icon getIcon() {
return UI5Icons.getIcon();
asebak/ui5-intellij-plugin
src/com/atsebak/ui5/autogeneration/Index.java
// Path: src/com/atsebak/ui5/AppType.java // public enum AppType { // DESKTOP, // MOBILE // }
import com.atsebak.ui5.AppType; import org.jetbrains.annotations.NotNull;
package com.atsebak.ui5.autogeneration; public class Index extends UI5View { @NotNull
// Path: src/com/atsebak/ui5/AppType.java // public enum AppType { // DESKTOP, // MOBILE // } // Path: src/com/atsebak/ui5/autogeneration/Index.java import com.atsebak.ui5.AppType; import org.jetbrains.annotations.NotNull; package com.atsebak.ui5.autogeneration; public class Index extends UI5View { @NotNull
public String createIndexCode(@NotNull AppType ui5Library, @NotNull String rootModuleName, @NotNull String initialViewExt) {
asebak/ui5-intellij-plugin
test/com/atsebak/ui5/autogeneration/IndexTest.java
// Path: src/com/atsebak/ui5/AppType.java // public enum AppType { // DESKTOP, // MOBILE // }
import com.atsebak.ui5.AppType; import org.junit.Test; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue;
package com.atsebak.ui5.autogeneration; public class IndexTest { @Test public void testCreateIndexCodeForDesktop() { Index index = new Index();
// Path: src/com/atsebak/ui5/AppType.java // public enum AppType { // DESKTOP, // MOBILE // } // Path: test/com/atsebak/ui5/autogeneration/IndexTest.java import com.atsebak.ui5.AppType; import org.junit.Test; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; package com.atsebak.ui5.autogeneration; public class IndexTest { @Test public void testCreateIndexCodeForDesktop() { Index index = new Index();
String js = index.createIndexCode(AppType.DESKTOP, "atsebak", "js");
asebak/ui5-intellij-plugin
test/com/atsebak/ui5/autogeneration/JSONViewTest.java
// Path: src/com/atsebak/ui5/AppType.java // public enum AppType { // DESKTOP, // MOBILE // }
import com.atsebak.ui5.AppType; import org.junit.Test; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat;
package com.atsebak.ui5.autogeneration; public class JSONViewTest { @Test public void testGetExtension() { UI5View view = new JSONView(); assertEquals(view.getExtension(), "json"); } @Test public void testAutogenerateCodeForDesktop() { UI5View view = new JSONView();
// Path: src/com/atsebak/ui5/AppType.java // public enum AppType { // DESKTOP, // MOBILE // } // Path: test/com/atsebak/ui5/autogeneration/JSONViewTest.java import com.atsebak.ui5.AppType; import org.junit.Test; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; package com.atsebak.ui5.autogeneration; public class JSONViewTest { @Test public void testGetExtension() { UI5View view = new JSONView(); assertEquals(view.getExtension(), "json"); } @Test public void testAutogenerateCodeForDesktop() { UI5View view = new JSONView();
String s = view.generateCode(AppType.DESKTOP, "com.atsebak");
asebak/ui5-intellij-plugin
src/com/atsebak/ui5/actions/search/SearchTermFinder.java
// Path: src/com/atsebak/ui5/util/SymbolExtractor.java // public final class SymbolExtractor { // // /** // * Private constructor // */ // private SymbolExtractor() { // // } // /** // * Extracts character sequence base on the position // * @param charSequence // * @param position // * @return // */ // public static String extract(CharSequence charSequence, int position) { // if (position > charSequence.length()) { // throw new IllegalStateException(); // } // if (position < 0) { // throw new IllegalStateException(); // } // // int first = position; // for (int c = position - 1; c >= 0; c--) { // if (Character.isJavaIdentifierPart(charSequence.charAt(c))) { // first = c; // } else { // break; // } // } // // int last = position; // for (int c = last; c <= charSequence.length(); c++) { // if (c == charSequence.length() || !Character // .isJavaIdentifierPart(charSequence.charAt(c))) { // last = c; // break; // } // } // // return charSequence.subSequence(first, last).toString(); // } // }
import com.atsebak.ui5.util.SymbolExtractor; import com.intellij.openapi.editor.Editor; import lombok.Builder;
package com.atsebak.ui5.actions.search; @Builder public class SearchTermFinder { private Editor editor; public String getSearchTerm() { String selectedText = editor.getSelectionModel().getSelectedText(); if (selectedText != null && selectedText.length() != 0) { if (selectedText.contains("\n")) { return ""; } else { return selectedText; } } int caretOffset = editor.getCaretModel().getOffset(); CharSequence charsSequence = editor.getDocument().getCharsSequence();
// Path: src/com/atsebak/ui5/util/SymbolExtractor.java // public final class SymbolExtractor { // // /** // * Private constructor // */ // private SymbolExtractor() { // // } // /** // * Extracts character sequence base on the position // * @param charSequence // * @param position // * @return // */ // public static String extract(CharSequence charSequence, int position) { // if (position > charSequence.length()) { // throw new IllegalStateException(); // } // if (position < 0) { // throw new IllegalStateException(); // } // // int first = position; // for (int c = position - 1; c >= 0; c--) { // if (Character.isJavaIdentifierPart(charSequence.charAt(c))) { // first = c; // } else { // break; // } // } // // int last = position; // for (int c = last; c <= charSequence.length(); c++) { // if (c == charSequence.length() || !Character // .isJavaIdentifierPart(charSequence.charAt(c))) { // last = c; // break; // } // } // // return charSequence.subSequence(first, last).toString(); // } // } // Path: src/com/atsebak/ui5/actions/search/SearchTermFinder.java import com.atsebak.ui5.util.SymbolExtractor; import com.intellij.openapi.editor.Editor; import lombok.Builder; package com.atsebak.ui5.actions.search; @Builder public class SearchTermFinder { private Editor editor; public String getSearchTerm() { String selectedText = editor.getSelectionModel().getSelectedText(); if (selectedText != null && selectedText.length() != 0) { if (selectedText.contains("\n")) { return ""; } else { return selectedText; } } int caretOffset = editor.getCaretModel().getOffset(); CharSequence charsSequence = editor.getDocument().getCharsSequence();
return SymbolExtractor.extract(charsSequence, caretOffset);
asebak/ui5-intellij-plugin
test/com/atsebak/ui5/autogeneration/JSViewTest.java
// Path: src/com/atsebak/ui5/AppType.java // public enum AppType { // DESKTOP, // MOBILE // }
import com.atsebak.ui5.AppType; import org.junit.Test; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat;
package com.atsebak.ui5.autogeneration; public class JSViewTest { @Test public void testGetExtension() { UI5View view = new JSView(); assertEquals(view.getExtension(), "js"); } @Test public void testAutogenerateCodeForDesktop() { UI5View view = new JSView();
// Path: src/com/atsebak/ui5/AppType.java // public enum AppType { // DESKTOP, // MOBILE // } // Path: test/com/atsebak/ui5/autogeneration/JSViewTest.java import com.atsebak.ui5.AppType; import org.junit.Test; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; package com.atsebak.ui5.autogeneration; public class JSViewTest { @Test public void testGetExtension() { UI5View view = new JSView(); assertEquals(view.getExtension(), "js"); } @Test public void testAutogenerateCodeForDesktop() { UI5View view = new JSView();
String s = view.generateCode(AppType.DESKTOP, "com.atsebak");
asebak/ui5-intellij-plugin
src/com/atsebak/ui5/autogeneration/UI5View.java
// Path: src/com/atsebak/ui5/AppType.java // public enum AppType { // DESKTOP, // MOBILE // }
import com.atsebak.ui5.AppType; import lombok.Getter; import lombok.NoArgsConstructor; import org.jetbrains.annotations.NotNull;
package com.atsebak.ui5.autogeneration; @NoArgsConstructor public abstract class UI5View { @Getter private final CodeGenerator codeGenerator = new CodeGenerator(); @Getter private String extension; public UI5View(@NotNull String extension) { this.extension = extension; } /** * Given the application type and the module path for generation * @param appType * @param controllerPath * @return */
// Path: src/com/atsebak/ui5/AppType.java // public enum AppType { // DESKTOP, // MOBILE // } // Path: src/com/atsebak/ui5/autogeneration/UI5View.java import com.atsebak.ui5.AppType; import lombok.Getter; import lombok.NoArgsConstructor; import org.jetbrains.annotations.NotNull; package com.atsebak.ui5.autogeneration; @NoArgsConstructor public abstract class UI5View { @Getter private final CodeGenerator codeGenerator = new CodeGenerator(); @Getter private String extension; public UI5View(@NotNull String extension) { this.extension = extension; } /** * Given the application type and the module path for generation * @param appType * @param controllerPath * @return */
public String generateCode(AppType appType, String controllerPath) {
asebak/ui5-intellij-plugin
src/com/atsebak/ui5/projectbuilder/UI5TemplatesFactory.java
// Path: src/com/atsebak/ui5/util/UI5Icons.java // public final class UI5Icons { // /** // * Private constructor // */ // private UI5Icons() { // // } // /** // * Get the Main UI5 Icon // * @return // */ // public static Icon getIcon(){ // return IconLoader.getIcon("/ui5.png", UI5Icons.class); // } // }
import com.atsebak.ui5.util.UI5Icons; import com.intellij.ide.util.projectWizard.WizardContext; import com.intellij.platform.ProjectTemplate; import com.intellij.platform.ProjectTemplatesFactory; import org.jetbrains.annotations.NotNull; import javax.swing.*;
package com.atsebak.ui5.projectbuilder; /** * This creates the Main division for the Project Template the getGroups() is the Root level of the template */ public class UI5TemplatesFactory extends ProjectTemplatesFactory { @NotNull @Override public String[] getGroups() { return new String[]{"SAP UI5"}; } @Override public Icon getGroupIcon(String s) {
// Path: src/com/atsebak/ui5/util/UI5Icons.java // public final class UI5Icons { // /** // * Private constructor // */ // private UI5Icons() { // // } // /** // * Get the Main UI5 Icon // * @return // */ // public static Icon getIcon(){ // return IconLoader.getIcon("/ui5.png", UI5Icons.class); // } // } // Path: src/com/atsebak/ui5/projectbuilder/UI5TemplatesFactory.java import com.atsebak.ui5.util.UI5Icons; import com.intellij.ide.util.projectWizard.WizardContext; import com.intellij.platform.ProjectTemplate; import com.intellij.platform.ProjectTemplatesFactory; import org.jetbrains.annotations.NotNull; import javax.swing.*; package com.atsebak.ui5.projectbuilder; /** * This creates the Main division for the Project Template the getGroups() is the Root level of the template */ public class UI5TemplatesFactory extends ProjectTemplatesFactory { @NotNull @Override public String[] getGroups() { return new String[]{"SAP UI5"}; } @Override public Icon getGroupIcon(String s) {
return UI5Icons.getIcon();
asebak/ui5-intellij-plugin
src/com/atsebak/ui5/projectbuilder/MobileTemplateGenerator.java
// Path: src/com/atsebak/ui5/AppType.java // public enum AppType { // DESKTOP, // MOBILE // } // // Path: src/com/atsebak/ui5/locale/UI5Bundle.java // public final class UI5Bundle { // // @NonNls // private static final String BUNDLE = "com.atsebak.ui5.locale.UI5Bundle"; // private static Reference<ResourceBundle> bundleReference; // // /** // * Private Constructor // */ // private UI5Bundle() { // } // // /** // * @param key // * @param params // * @return // */ // public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { // return BundleBase.message(getBundle(), key, params); // } // // /** // * @return // */ // private static ResourceBundle getBundle() { // ResourceBundle bundle = dereference(bundleReference); // if (bundle == null) { // bundle = ResourceBundle.getBundle(BUNDLE); // bundleReference = new SoftReference<ResourceBundle>(bundle); // } // return bundle; // } // // /** // * @param key The Key // * @return The Localized Text // */ // public static String getString(@PropertyKey(resourceBundle = BUNDLE) final String key) { // return getBundle().getString(key); // } // }
import com.atsebak.ui5.AppType; import com.atsebak.ui5.locale.UI5Bundle; import com.intellij.icons.AllIcons; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import javax.swing.*;
package com.atsebak.ui5.projectbuilder; public class MobileTemplateGenerator extends UI5ProjectTemplateGenerator { @Nls @NotNull @Override public String getName() {
// Path: src/com/atsebak/ui5/AppType.java // public enum AppType { // DESKTOP, // MOBILE // } // // Path: src/com/atsebak/ui5/locale/UI5Bundle.java // public final class UI5Bundle { // // @NonNls // private static final String BUNDLE = "com.atsebak.ui5.locale.UI5Bundle"; // private static Reference<ResourceBundle> bundleReference; // // /** // * Private Constructor // */ // private UI5Bundle() { // } // // /** // * @param key // * @param params // * @return // */ // public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { // return BundleBase.message(getBundle(), key, params); // } // // /** // * @return // */ // private static ResourceBundle getBundle() { // ResourceBundle bundle = dereference(bundleReference); // if (bundle == null) { // bundle = ResourceBundle.getBundle(BUNDLE); // bundleReference = new SoftReference<ResourceBundle>(bundle); // } // return bundle; // } // // /** // * @param key The Key // * @return The Localized Text // */ // public static String getString(@PropertyKey(resourceBundle = BUNDLE) final String key) { // return getBundle().getString(key); // } // } // Path: src/com/atsebak/ui5/projectbuilder/MobileTemplateGenerator.java import com.atsebak.ui5.AppType; import com.atsebak.ui5.locale.UI5Bundle; import com.intellij.icons.AllIcons; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import javax.swing.*; package com.atsebak.ui5.projectbuilder; public class MobileTemplateGenerator extends UI5ProjectTemplateGenerator { @Nls @NotNull @Override public String getName() {
return UI5Bundle.getString("mobile.app");
asebak/ui5-intellij-plugin
src/com/atsebak/ui5/projectbuilder/MobileTemplateGenerator.java
// Path: src/com/atsebak/ui5/AppType.java // public enum AppType { // DESKTOP, // MOBILE // } // // Path: src/com/atsebak/ui5/locale/UI5Bundle.java // public final class UI5Bundle { // // @NonNls // private static final String BUNDLE = "com.atsebak.ui5.locale.UI5Bundle"; // private static Reference<ResourceBundle> bundleReference; // // /** // * Private Constructor // */ // private UI5Bundle() { // } // // /** // * @param key // * @param params // * @return // */ // public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { // return BundleBase.message(getBundle(), key, params); // } // // /** // * @return // */ // private static ResourceBundle getBundle() { // ResourceBundle bundle = dereference(bundleReference); // if (bundle == null) { // bundle = ResourceBundle.getBundle(BUNDLE); // bundleReference = new SoftReference<ResourceBundle>(bundle); // } // return bundle; // } // // /** // * @param key The Key // * @return The Localized Text // */ // public static String getString(@PropertyKey(resourceBundle = BUNDLE) final String key) { // return getBundle().getString(key); // } // }
import com.atsebak.ui5.AppType; import com.atsebak.ui5.locale.UI5Bundle; import com.intellij.icons.AllIcons; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import javax.swing.*;
package com.atsebak.ui5.projectbuilder; public class MobileTemplateGenerator extends UI5ProjectTemplateGenerator { @Nls @NotNull @Override public String getName() { return UI5Bundle.getString("mobile.app"); } @Override public String getDescription() { return UI5Bundle.getString("mobile.description"); } @Override public Icon getIcon() { return AllIcons.General.CreateNewProject; } @Override public void generateProject(@NotNull Project project, @NotNull VirtualFile virtualFile, @NotNull UI5ProjectSettings settings, @NotNull Module module) {
// Path: src/com/atsebak/ui5/AppType.java // public enum AppType { // DESKTOP, // MOBILE // } // // Path: src/com/atsebak/ui5/locale/UI5Bundle.java // public final class UI5Bundle { // // @NonNls // private static final String BUNDLE = "com.atsebak.ui5.locale.UI5Bundle"; // private static Reference<ResourceBundle> bundleReference; // // /** // * Private Constructor // */ // private UI5Bundle() { // } // // /** // * @param key // * @param params // * @return // */ // public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { // return BundleBase.message(getBundle(), key, params); // } // // /** // * @return // */ // private static ResourceBundle getBundle() { // ResourceBundle bundle = dereference(bundleReference); // if (bundle == null) { // bundle = ResourceBundle.getBundle(BUNDLE); // bundleReference = new SoftReference<ResourceBundle>(bundle); // } // return bundle; // } // // /** // * @param key The Key // * @return The Localized Text // */ // public static String getString(@PropertyKey(resourceBundle = BUNDLE) final String key) { // return getBundle().getString(key); // } // } // Path: src/com/atsebak/ui5/projectbuilder/MobileTemplateGenerator.java import com.atsebak.ui5.AppType; import com.atsebak.ui5.locale.UI5Bundle; import com.intellij.icons.AllIcons; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import javax.swing.*; package com.atsebak.ui5.projectbuilder; public class MobileTemplateGenerator extends UI5ProjectTemplateGenerator { @Nls @NotNull @Override public String getName() { return UI5Bundle.getString("mobile.app"); } @Override public String getDescription() { return UI5Bundle.getString("mobile.description"); } @Override public Icon getIcon() { return AllIcons.General.CreateNewProject; } @Override public void generateProject(@NotNull Project project, @NotNull VirtualFile virtualFile, @NotNull UI5ProjectSettings settings, @NotNull Module module) {
settings.setLibrary(AppType.MOBILE);
asebak/ui5-intellij-plugin
src/com/atsebak/ui5/projectbuilder/ProjectPeer.java
// Path: src/com/atsebak/ui5/FileType.java // public enum FileType { // JS, // XML, // HTML, // JSON, // PROPERTIES // } // // Path: src/com/atsebak/ui5/autogeneration/UI5View.java // @NoArgsConstructor // public abstract class UI5View { // @Getter // private final CodeGenerator codeGenerator = new CodeGenerator(); // @Getter // private String extension; // // public UI5View(@NotNull String extension) { // this.extension = extension; // } // // /** // * Given the application type and the module path for generation // * @param appType // * @param controllerPath // * @return // */ // public String generateCode(AppType appType, String controllerPath) { // return codeGenerator.createViewCode(appType, controllerPath, extension); // } // } // // Path: src/com/atsebak/ui5/locale/UI5Bundle.java // public final class UI5Bundle { // // @NonNls // private static final String BUNDLE = "com.atsebak.ui5.locale.UI5Bundle"; // private static Reference<ResourceBundle> bundleReference; // // /** // * Private Constructor // */ // private UI5Bundle() { // } // // /** // * @param key // * @param params // * @return // */ // public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { // return BundleBase.message(getBundle(), key, params); // } // // /** // * @return // */ // private static ResourceBundle getBundle() { // ResourceBundle bundle = dereference(bundleReference); // if (bundle == null) { // bundle = ResourceBundle.getBundle(BUNDLE); // bundleReference = new SoftReference<ResourceBundle>(bundle); // } // return bundle; // } // // /** // * @param key The Key // * @return The Localized Text // */ // public static String getString(@PropertyKey(resourceBundle = BUNDLE) final String key) { // return getBundle().getString(key); // } // } // // Path: src/com/atsebak/ui5/util/UI5FileBuilder.java // public final class UI5FileBuilder { // // /** // * Creates a directory from a given name // * // * @param folder // * @param name // */ // public static void createDirectoryFromName(@NotNull File folder, @NotNull String name) { // File file = new File(folder, name); // file.mkdir(); // } // // /** // * Gets the module path based on the psidirectory passed // * // * @param psiDirectory // * @return // */ // public static String getModulePath(@NotNull PsiDirectory psiDirectory) { // Module module = ModuleUtilCore.findModuleForPsiElement(psiDirectory.getOriginalElement()); // if (module != null) { // String[] projectDircs; // String[] fileDircs; // String projectPath = module.getProject().getBasePath(); // String filePath = new File(psiDirectory.getVirtualFile().getPath()).getPath(); // assert projectPath != null; // projectDircs = projectPath.split(Pattern.quote(File.separator)); // fileDircs = filePath.split(Pattern.quote(File.separator)); // for (int i = 0; i < projectDircs.length; i++) { // if (projectDircs[i].equals(fileDircs[i])) { // fileDircs[i] = ""; // } // } // String codePath = ""; // for (int i = 0; i < fileDircs.length; i++) { // if (!fileDircs[i].isEmpty()) { // codePath += fileDircs[i]; // if (i != fileDircs.length - 1) { // codePath += "."; // } // } // // } // return codePath; // } // return ""; // } // // /** // * Get the interface implementation // * // * @param type // * @return // */ // public static UI5View getViewImplementation(@NotNull FileType type) { // switch (type) { // case JS: // return new JSView(); // case XML: // return new XMLView(); // case HTML: // return new HTMLView(); // case JSON: // return new JSONView(); // } // return null; // } // }
import com.atsebak.ui5.FileType; import com.atsebak.ui5.autogeneration.UI5View; import com.atsebak.ui5.locale.UI5Bundle; import com.atsebak.ui5.util.UI5FileBuilder; import com.intellij.ide.util.projectWizard.SettingsStep; import com.intellij.openapi.ui.ValidationInfo; import com.intellij.platform.WebProjectGenerator; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.util.Enumeration;
package com.atsebak.ui5.projectbuilder; public class ProjectPeer implements WebProjectGenerator.GeneratorPeer<UI5ProjectTemplateGenerator.UI5ProjectSettings> { private final java.util.List<WebProjectGenerator.SettingsStateListener> stateListeners = ContainerUtil.createLockFreeCopyOnWriteList(); private UI5ProjectTemplateGenerator.UI5ProjectSettings settings = new UI5ProjectTemplateGenerator.UI5ProjectSettings(); private ButtonGroup viewTypeButtonGroup = new ButtonGroup(); private JRadioButton javascriptRadioButton; private JRadioButton XMLRadioButton; private JRadioButton HTMLRadioButton; private JRadioButton JSONRadioButton; private JPanel panel; private JPanel viewPanel; public ProjectPeer() { viewTypeButtonGroup.add(javascriptRadioButton); viewTypeButtonGroup.add(XMLRadioButton); viewTypeButtonGroup.add(HTMLRadioButton); viewTypeButtonGroup.add(JSONRadioButton); } @NotNull @Override public JComponent getComponent() { return null; } @Override public void buildUI(@NotNull SettingsStep settingsStep) {
// Path: src/com/atsebak/ui5/FileType.java // public enum FileType { // JS, // XML, // HTML, // JSON, // PROPERTIES // } // // Path: src/com/atsebak/ui5/autogeneration/UI5View.java // @NoArgsConstructor // public abstract class UI5View { // @Getter // private final CodeGenerator codeGenerator = new CodeGenerator(); // @Getter // private String extension; // // public UI5View(@NotNull String extension) { // this.extension = extension; // } // // /** // * Given the application type and the module path for generation // * @param appType // * @param controllerPath // * @return // */ // public String generateCode(AppType appType, String controllerPath) { // return codeGenerator.createViewCode(appType, controllerPath, extension); // } // } // // Path: src/com/atsebak/ui5/locale/UI5Bundle.java // public final class UI5Bundle { // // @NonNls // private static final String BUNDLE = "com.atsebak.ui5.locale.UI5Bundle"; // private static Reference<ResourceBundle> bundleReference; // // /** // * Private Constructor // */ // private UI5Bundle() { // } // // /** // * @param key // * @param params // * @return // */ // public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { // return BundleBase.message(getBundle(), key, params); // } // // /** // * @return // */ // private static ResourceBundle getBundle() { // ResourceBundle bundle = dereference(bundleReference); // if (bundle == null) { // bundle = ResourceBundle.getBundle(BUNDLE); // bundleReference = new SoftReference<ResourceBundle>(bundle); // } // return bundle; // } // // /** // * @param key The Key // * @return The Localized Text // */ // public static String getString(@PropertyKey(resourceBundle = BUNDLE) final String key) { // return getBundle().getString(key); // } // } // // Path: src/com/atsebak/ui5/util/UI5FileBuilder.java // public final class UI5FileBuilder { // // /** // * Creates a directory from a given name // * // * @param folder // * @param name // */ // public static void createDirectoryFromName(@NotNull File folder, @NotNull String name) { // File file = new File(folder, name); // file.mkdir(); // } // // /** // * Gets the module path based on the psidirectory passed // * // * @param psiDirectory // * @return // */ // public static String getModulePath(@NotNull PsiDirectory psiDirectory) { // Module module = ModuleUtilCore.findModuleForPsiElement(psiDirectory.getOriginalElement()); // if (module != null) { // String[] projectDircs; // String[] fileDircs; // String projectPath = module.getProject().getBasePath(); // String filePath = new File(psiDirectory.getVirtualFile().getPath()).getPath(); // assert projectPath != null; // projectDircs = projectPath.split(Pattern.quote(File.separator)); // fileDircs = filePath.split(Pattern.quote(File.separator)); // for (int i = 0; i < projectDircs.length; i++) { // if (projectDircs[i].equals(fileDircs[i])) { // fileDircs[i] = ""; // } // } // String codePath = ""; // for (int i = 0; i < fileDircs.length; i++) { // if (!fileDircs[i].isEmpty()) { // codePath += fileDircs[i]; // if (i != fileDircs.length - 1) { // codePath += "."; // } // } // // } // return codePath; // } // return ""; // } // // /** // * Get the interface implementation // * // * @param type // * @return // */ // public static UI5View getViewImplementation(@NotNull FileType type) { // switch (type) { // case JS: // return new JSView(); // case XML: // return new XMLView(); // case HTML: // return new HTMLView(); // case JSON: // return new JSONView(); // } // return null; // } // } // Path: src/com/atsebak/ui5/projectbuilder/ProjectPeer.java import com.atsebak.ui5.FileType; import com.atsebak.ui5.autogeneration.UI5View; import com.atsebak.ui5.locale.UI5Bundle; import com.atsebak.ui5.util.UI5FileBuilder; import com.intellij.ide.util.projectWizard.SettingsStep; import com.intellij.openapi.ui.ValidationInfo; import com.intellij.platform.WebProjectGenerator; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.util.Enumeration; package com.atsebak.ui5.projectbuilder; public class ProjectPeer implements WebProjectGenerator.GeneratorPeer<UI5ProjectTemplateGenerator.UI5ProjectSettings> { private final java.util.List<WebProjectGenerator.SettingsStateListener> stateListeners = ContainerUtil.createLockFreeCopyOnWriteList(); private UI5ProjectTemplateGenerator.UI5ProjectSettings settings = new UI5ProjectTemplateGenerator.UI5ProjectSettings(); private ButtonGroup viewTypeButtonGroup = new ButtonGroup(); private JRadioButton javascriptRadioButton; private JRadioButton XMLRadioButton; private JRadioButton HTMLRadioButton; private JRadioButton JSONRadioButton; private JPanel panel; private JPanel viewPanel; public ProjectPeer() { viewTypeButtonGroup.add(javascriptRadioButton); viewTypeButtonGroup.add(XMLRadioButton); viewTypeButtonGroup.add(HTMLRadioButton); viewTypeButtonGroup.add(JSONRadioButton); } @NotNull @Override public JComponent getComponent() { return null; } @Override public void buildUI(@NotNull SettingsStep settingsStep) {
settingsStep.addSettingsField(UI5Bundle.getString("view.type"), viewPanel);
asebak/ui5-intellij-plugin
src/com/atsebak/ui5/projectbuilder/ProjectPeer.java
// Path: src/com/atsebak/ui5/FileType.java // public enum FileType { // JS, // XML, // HTML, // JSON, // PROPERTIES // } // // Path: src/com/atsebak/ui5/autogeneration/UI5View.java // @NoArgsConstructor // public abstract class UI5View { // @Getter // private final CodeGenerator codeGenerator = new CodeGenerator(); // @Getter // private String extension; // // public UI5View(@NotNull String extension) { // this.extension = extension; // } // // /** // * Given the application type and the module path for generation // * @param appType // * @param controllerPath // * @return // */ // public String generateCode(AppType appType, String controllerPath) { // return codeGenerator.createViewCode(appType, controllerPath, extension); // } // } // // Path: src/com/atsebak/ui5/locale/UI5Bundle.java // public final class UI5Bundle { // // @NonNls // private static final String BUNDLE = "com.atsebak.ui5.locale.UI5Bundle"; // private static Reference<ResourceBundle> bundleReference; // // /** // * Private Constructor // */ // private UI5Bundle() { // } // // /** // * @param key // * @param params // * @return // */ // public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { // return BundleBase.message(getBundle(), key, params); // } // // /** // * @return // */ // private static ResourceBundle getBundle() { // ResourceBundle bundle = dereference(bundleReference); // if (bundle == null) { // bundle = ResourceBundle.getBundle(BUNDLE); // bundleReference = new SoftReference<ResourceBundle>(bundle); // } // return bundle; // } // // /** // * @param key The Key // * @return The Localized Text // */ // public static String getString(@PropertyKey(resourceBundle = BUNDLE) final String key) { // return getBundle().getString(key); // } // } // // Path: src/com/atsebak/ui5/util/UI5FileBuilder.java // public final class UI5FileBuilder { // // /** // * Creates a directory from a given name // * // * @param folder // * @param name // */ // public static void createDirectoryFromName(@NotNull File folder, @NotNull String name) { // File file = new File(folder, name); // file.mkdir(); // } // // /** // * Gets the module path based on the psidirectory passed // * // * @param psiDirectory // * @return // */ // public static String getModulePath(@NotNull PsiDirectory psiDirectory) { // Module module = ModuleUtilCore.findModuleForPsiElement(psiDirectory.getOriginalElement()); // if (module != null) { // String[] projectDircs; // String[] fileDircs; // String projectPath = module.getProject().getBasePath(); // String filePath = new File(psiDirectory.getVirtualFile().getPath()).getPath(); // assert projectPath != null; // projectDircs = projectPath.split(Pattern.quote(File.separator)); // fileDircs = filePath.split(Pattern.quote(File.separator)); // for (int i = 0; i < projectDircs.length; i++) { // if (projectDircs[i].equals(fileDircs[i])) { // fileDircs[i] = ""; // } // } // String codePath = ""; // for (int i = 0; i < fileDircs.length; i++) { // if (!fileDircs[i].isEmpty()) { // codePath += fileDircs[i]; // if (i != fileDircs.length - 1) { // codePath += "."; // } // } // // } // return codePath; // } // return ""; // } // // /** // * Get the interface implementation // * // * @param type // * @return // */ // public static UI5View getViewImplementation(@NotNull FileType type) { // switch (type) { // case JS: // return new JSView(); // case XML: // return new XMLView(); // case HTML: // return new HTMLView(); // case JSON: // return new JSONView(); // } // return null; // } // }
import com.atsebak.ui5.FileType; import com.atsebak.ui5.autogeneration.UI5View; import com.atsebak.ui5.locale.UI5Bundle; import com.atsebak.ui5.util.UI5FileBuilder; import com.intellij.ide.util.projectWizard.SettingsStep; import com.intellij.openapi.ui.ValidationInfo; import com.intellij.platform.WebProjectGenerator; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.util.Enumeration;
package com.atsebak.ui5.projectbuilder; public class ProjectPeer implements WebProjectGenerator.GeneratorPeer<UI5ProjectTemplateGenerator.UI5ProjectSettings> { private final java.util.List<WebProjectGenerator.SettingsStateListener> stateListeners = ContainerUtil.createLockFreeCopyOnWriteList(); private UI5ProjectTemplateGenerator.UI5ProjectSettings settings = new UI5ProjectTemplateGenerator.UI5ProjectSettings(); private ButtonGroup viewTypeButtonGroup = new ButtonGroup(); private JRadioButton javascriptRadioButton; private JRadioButton XMLRadioButton; private JRadioButton HTMLRadioButton; private JRadioButton JSONRadioButton; private JPanel panel; private JPanel viewPanel; public ProjectPeer() { viewTypeButtonGroup.add(javascriptRadioButton); viewTypeButtonGroup.add(XMLRadioButton); viewTypeButtonGroup.add(HTMLRadioButton); viewTypeButtonGroup.add(JSONRadioButton); } @NotNull @Override public JComponent getComponent() { return null; } @Override public void buildUI(@NotNull SettingsStep settingsStep) { settingsStep.addSettingsField(UI5Bundle.getString("view.type"), viewPanel); } @NotNull @Override public UI5ProjectTemplateGenerator.UI5ProjectSettings getSettings() { String viewType = getSelectedButton(viewTypeButtonGroup);
// Path: src/com/atsebak/ui5/FileType.java // public enum FileType { // JS, // XML, // HTML, // JSON, // PROPERTIES // } // // Path: src/com/atsebak/ui5/autogeneration/UI5View.java // @NoArgsConstructor // public abstract class UI5View { // @Getter // private final CodeGenerator codeGenerator = new CodeGenerator(); // @Getter // private String extension; // // public UI5View(@NotNull String extension) { // this.extension = extension; // } // // /** // * Given the application type and the module path for generation // * @param appType // * @param controllerPath // * @return // */ // public String generateCode(AppType appType, String controllerPath) { // return codeGenerator.createViewCode(appType, controllerPath, extension); // } // } // // Path: src/com/atsebak/ui5/locale/UI5Bundle.java // public final class UI5Bundle { // // @NonNls // private static final String BUNDLE = "com.atsebak.ui5.locale.UI5Bundle"; // private static Reference<ResourceBundle> bundleReference; // // /** // * Private Constructor // */ // private UI5Bundle() { // } // // /** // * @param key // * @param params // * @return // */ // public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { // return BundleBase.message(getBundle(), key, params); // } // // /** // * @return // */ // private static ResourceBundle getBundle() { // ResourceBundle bundle = dereference(bundleReference); // if (bundle == null) { // bundle = ResourceBundle.getBundle(BUNDLE); // bundleReference = new SoftReference<ResourceBundle>(bundle); // } // return bundle; // } // // /** // * @param key The Key // * @return The Localized Text // */ // public static String getString(@PropertyKey(resourceBundle = BUNDLE) final String key) { // return getBundle().getString(key); // } // } // // Path: src/com/atsebak/ui5/util/UI5FileBuilder.java // public final class UI5FileBuilder { // // /** // * Creates a directory from a given name // * // * @param folder // * @param name // */ // public static void createDirectoryFromName(@NotNull File folder, @NotNull String name) { // File file = new File(folder, name); // file.mkdir(); // } // // /** // * Gets the module path based on the psidirectory passed // * // * @param psiDirectory // * @return // */ // public static String getModulePath(@NotNull PsiDirectory psiDirectory) { // Module module = ModuleUtilCore.findModuleForPsiElement(psiDirectory.getOriginalElement()); // if (module != null) { // String[] projectDircs; // String[] fileDircs; // String projectPath = module.getProject().getBasePath(); // String filePath = new File(psiDirectory.getVirtualFile().getPath()).getPath(); // assert projectPath != null; // projectDircs = projectPath.split(Pattern.quote(File.separator)); // fileDircs = filePath.split(Pattern.quote(File.separator)); // for (int i = 0; i < projectDircs.length; i++) { // if (projectDircs[i].equals(fileDircs[i])) { // fileDircs[i] = ""; // } // } // String codePath = ""; // for (int i = 0; i < fileDircs.length; i++) { // if (!fileDircs[i].isEmpty()) { // codePath += fileDircs[i]; // if (i != fileDircs.length - 1) { // codePath += "."; // } // } // // } // return codePath; // } // return ""; // } // // /** // * Get the interface implementation // * // * @param type // * @return // */ // public static UI5View getViewImplementation(@NotNull FileType type) { // switch (type) { // case JS: // return new JSView(); // case XML: // return new XMLView(); // case HTML: // return new HTMLView(); // case JSON: // return new JSONView(); // } // return null; // } // } // Path: src/com/atsebak/ui5/projectbuilder/ProjectPeer.java import com.atsebak.ui5.FileType; import com.atsebak.ui5.autogeneration.UI5View; import com.atsebak.ui5.locale.UI5Bundle; import com.atsebak.ui5.util.UI5FileBuilder; import com.intellij.ide.util.projectWizard.SettingsStep; import com.intellij.openapi.ui.ValidationInfo; import com.intellij.platform.WebProjectGenerator; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.util.Enumeration; package com.atsebak.ui5.projectbuilder; public class ProjectPeer implements WebProjectGenerator.GeneratorPeer<UI5ProjectTemplateGenerator.UI5ProjectSettings> { private final java.util.List<WebProjectGenerator.SettingsStateListener> stateListeners = ContainerUtil.createLockFreeCopyOnWriteList(); private UI5ProjectTemplateGenerator.UI5ProjectSettings settings = new UI5ProjectTemplateGenerator.UI5ProjectSettings(); private ButtonGroup viewTypeButtonGroup = new ButtonGroup(); private JRadioButton javascriptRadioButton; private JRadioButton XMLRadioButton; private JRadioButton HTMLRadioButton; private JRadioButton JSONRadioButton; private JPanel panel; private JPanel viewPanel; public ProjectPeer() { viewTypeButtonGroup.add(javascriptRadioButton); viewTypeButtonGroup.add(XMLRadioButton); viewTypeButtonGroup.add(HTMLRadioButton); viewTypeButtonGroup.add(JSONRadioButton); } @NotNull @Override public JComponent getComponent() { return null; } @Override public void buildUI(@NotNull SettingsStep settingsStep) { settingsStep.addSettingsField(UI5Bundle.getString("view.type"), viewPanel); } @NotNull @Override public UI5ProjectTemplateGenerator.UI5ProjectSettings getSettings() { String viewType = getSelectedButton(viewTypeButtonGroup);
UI5View view = UI5FileBuilder.getViewImplementation(FileType.valueOf(viewType));
asebak/ui5-intellij-plugin
src/com/atsebak/ui5/projectbuilder/ProjectPeer.java
// Path: src/com/atsebak/ui5/FileType.java // public enum FileType { // JS, // XML, // HTML, // JSON, // PROPERTIES // } // // Path: src/com/atsebak/ui5/autogeneration/UI5View.java // @NoArgsConstructor // public abstract class UI5View { // @Getter // private final CodeGenerator codeGenerator = new CodeGenerator(); // @Getter // private String extension; // // public UI5View(@NotNull String extension) { // this.extension = extension; // } // // /** // * Given the application type and the module path for generation // * @param appType // * @param controllerPath // * @return // */ // public String generateCode(AppType appType, String controllerPath) { // return codeGenerator.createViewCode(appType, controllerPath, extension); // } // } // // Path: src/com/atsebak/ui5/locale/UI5Bundle.java // public final class UI5Bundle { // // @NonNls // private static final String BUNDLE = "com.atsebak.ui5.locale.UI5Bundle"; // private static Reference<ResourceBundle> bundleReference; // // /** // * Private Constructor // */ // private UI5Bundle() { // } // // /** // * @param key // * @param params // * @return // */ // public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { // return BundleBase.message(getBundle(), key, params); // } // // /** // * @return // */ // private static ResourceBundle getBundle() { // ResourceBundle bundle = dereference(bundleReference); // if (bundle == null) { // bundle = ResourceBundle.getBundle(BUNDLE); // bundleReference = new SoftReference<ResourceBundle>(bundle); // } // return bundle; // } // // /** // * @param key The Key // * @return The Localized Text // */ // public static String getString(@PropertyKey(resourceBundle = BUNDLE) final String key) { // return getBundle().getString(key); // } // } // // Path: src/com/atsebak/ui5/util/UI5FileBuilder.java // public final class UI5FileBuilder { // // /** // * Creates a directory from a given name // * // * @param folder // * @param name // */ // public static void createDirectoryFromName(@NotNull File folder, @NotNull String name) { // File file = new File(folder, name); // file.mkdir(); // } // // /** // * Gets the module path based on the psidirectory passed // * // * @param psiDirectory // * @return // */ // public static String getModulePath(@NotNull PsiDirectory psiDirectory) { // Module module = ModuleUtilCore.findModuleForPsiElement(psiDirectory.getOriginalElement()); // if (module != null) { // String[] projectDircs; // String[] fileDircs; // String projectPath = module.getProject().getBasePath(); // String filePath = new File(psiDirectory.getVirtualFile().getPath()).getPath(); // assert projectPath != null; // projectDircs = projectPath.split(Pattern.quote(File.separator)); // fileDircs = filePath.split(Pattern.quote(File.separator)); // for (int i = 0; i < projectDircs.length; i++) { // if (projectDircs[i].equals(fileDircs[i])) { // fileDircs[i] = ""; // } // } // String codePath = ""; // for (int i = 0; i < fileDircs.length; i++) { // if (!fileDircs[i].isEmpty()) { // codePath += fileDircs[i]; // if (i != fileDircs.length - 1) { // codePath += "."; // } // } // // } // return codePath; // } // return ""; // } // // /** // * Get the interface implementation // * // * @param type // * @return // */ // public static UI5View getViewImplementation(@NotNull FileType type) { // switch (type) { // case JS: // return new JSView(); // case XML: // return new XMLView(); // case HTML: // return new HTMLView(); // case JSON: // return new JSONView(); // } // return null; // } // }
import com.atsebak.ui5.FileType; import com.atsebak.ui5.autogeneration.UI5View; import com.atsebak.ui5.locale.UI5Bundle; import com.atsebak.ui5.util.UI5FileBuilder; import com.intellij.ide.util.projectWizard.SettingsStep; import com.intellij.openapi.ui.ValidationInfo; import com.intellij.platform.WebProjectGenerator; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.util.Enumeration;
package com.atsebak.ui5.projectbuilder; public class ProjectPeer implements WebProjectGenerator.GeneratorPeer<UI5ProjectTemplateGenerator.UI5ProjectSettings> { private final java.util.List<WebProjectGenerator.SettingsStateListener> stateListeners = ContainerUtil.createLockFreeCopyOnWriteList(); private UI5ProjectTemplateGenerator.UI5ProjectSettings settings = new UI5ProjectTemplateGenerator.UI5ProjectSettings(); private ButtonGroup viewTypeButtonGroup = new ButtonGroup(); private JRadioButton javascriptRadioButton; private JRadioButton XMLRadioButton; private JRadioButton HTMLRadioButton; private JRadioButton JSONRadioButton; private JPanel panel; private JPanel viewPanel; public ProjectPeer() { viewTypeButtonGroup.add(javascriptRadioButton); viewTypeButtonGroup.add(XMLRadioButton); viewTypeButtonGroup.add(HTMLRadioButton); viewTypeButtonGroup.add(JSONRadioButton); } @NotNull @Override public JComponent getComponent() { return null; } @Override public void buildUI(@NotNull SettingsStep settingsStep) { settingsStep.addSettingsField(UI5Bundle.getString("view.type"), viewPanel); } @NotNull @Override public UI5ProjectTemplateGenerator.UI5ProjectSettings getSettings() { String viewType = getSelectedButton(viewTypeButtonGroup);
// Path: src/com/atsebak/ui5/FileType.java // public enum FileType { // JS, // XML, // HTML, // JSON, // PROPERTIES // } // // Path: src/com/atsebak/ui5/autogeneration/UI5View.java // @NoArgsConstructor // public abstract class UI5View { // @Getter // private final CodeGenerator codeGenerator = new CodeGenerator(); // @Getter // private String extension; // // public UI5View(@NotNull String extension) { // this.extension = extension; // } // // /** // * Given the application type and the module path for generation // * @param appType // * @param controllerPath // * @return // */ // public String generateCode(AppType appType, String controllerPath) { // return codeGenerator.createViewCode(appType, controllerPath, extension); // } // } // // Path: src/com/atsebak/ui5/locale/UI5Bundle.java // public final class UI5Bundle { // // @NonNls // private static final String BUNDLE = "com.atsebak.ui5.locale.UI5Bundle"; // private static Reference<ResourceBundle> bundleReference; // // /** // * Private Constructor // */ // private UI5Bundle() { // } // // /** // * @param key // * @param params // * @return // */ // public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { // return BundleBase.message(getBundle(), key, params); // } // // /** // * @return // */ // private static ResourceBundle getBundle() { // ResourceBundle bundle = dereference(bundleReference); // if (bundle == null) { // bundle = ResourceBundle.getBundle(BUNDLE); // bundleReference = new SoftReference<ResourceBundle>(bundle); // } // return bundle; // } // // /** // * @param key The Key // * @return The Localized Text // */ // public static String getString(@PropertyKey(resourceBundle = BUNDLE) final String key) { // return getBundle().getString(key); // } // } // // Path: src/com/atsebak/ui5/util/UI5FileBuilder.java // public final class UI5FileBuilder { // // /** // * Creates a directory from a given name // * // * @param folder // * @param name // */ // public static void createDirectoryFromName(@NotNull File folder, @NotNull String name) { // File file = new File(folder, name); // file.mkdir(); // } // // /** // * Gets the module path based on the psidirectory passed // * // * @param psiDirectory // * @return // */ // public static String getModulePath(@NotNull PsiDirectory psiDirectory) { // Module module = ModuleUtilCore.findModuleForPsiElement(psiDirectory.getOriginalElement()); // if (module != null) { // String[] projectDircs; // String[] fileDircs; // String projectPath = module.getProject().getBasePath(); // String filePath = new File(psiDirectory.getVirtualFile().getPath()).getPath(); // assert projectPath != null; // projectDircs = projectPath.split(Pattern.quote(File.separator)); // fileDircs = filePath.split(Pattern.quote(File.separator)); // for (int i = 0; i < projectDircs.length; i++) { // if (projectDircs[i].equals(fileDircs[i])) { // fileDircs[i] = ""; // } // } // String codePath = ""; // for (int i = 0; i < fileDircs.length; i++) { // if (!fileDircs[i].isEmpty()) { // codePath += fileDircs[i]; // if (i != fileDircs.length - 1) { // codePath += "."; // } // } // // } // return codePath; // } // return ""; // } // // /** // * Get the interface implementation // * // * @param type // * @return // */ // public static UI5View getViewImplementation(@NotNull FileType type) { // switch (type) { // case JS: // return new JSView(); // case XML: // return new XMLView(); // case HTML: // return new HTMLView(); // case JSON: // return new JSONView(); // } // return null; // } // } // Path: src/com/atsebak/ui5/projectbuilder/ProjectPeer.java import com.atsebak.ui5.FileType; import com.atsebak.ui5.autogeneration.UI5View; import com.atsebak.ui5.locale.UI5Bundle; import com.atsebak.ui5.util.UI5FileBuilder; import com.intellij.ide.util.projectWizard.SettingsStep; import com.intellij.openapi.ui.ValidationInfo; import com.intellij.platform.WebProjectGenerator; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.util.Enumeration; package com.atsebak.ui5.projectbuilder; public class ProjectPeer implements WebProjectGenerator.GeneratorPeer<UI5ProjectTemplateGenerator.UI5ProjectSettings> { private final java.util.List<WebProjectGenerator.SettingsStateListener> stateListeners = ContainerUtil.createLockFreeCopyOnWriteList(); private UI5ProjectTemplateGenerator.UI5ProjectSettings settings = new UI5ProjectTemplateGenerator.UI5ProjectSettings(); private ButtonGroup viewTypeButtonGroup = new ButtonGroup(); private JRadioButton javascriptRadioButton; private JRadioButton XMLRadioButton; private JRadioButton HTMLRadioButton; private JRadioButton JSONRadioButton; private JPanel panel; private JPanel viewPanel; public ProjectPeer() { viewTypeButtonGroup.add(javascriptRadioButton); viewTypeButtonGroup.add(XMLRadioButton); viewTypeButtonGroup.add(HTMLRadioButton); viewTypeButtonGroup.add(JSONRadioButton); } @NotNull @Override public JComponent getComponent() { return null; } @Override public void buildUI(@NotNull SettingsStep settingsStep) { settingsStep.addSettingsField(UI5Bundle.getString("view.type"), viewPanel); } @NotNull @Override public UI5ProjectTemplateGenerator.UI5ProjectSettings getSettings() { String viewType = getSelectedButton(viewTypeButtonGroup);
UI5View view = UI5FileBuilder.getViewImplementation(FileType.valueOf(viewType));
asebak/ui5-intellij-plugin
src/com/atsebak/ui5/projectbuilder/ProjectPeer.java
// Path: src/com/atsebak/ui5/FileType.java // public enum FileType { // JS, // XML, // HTML, // JSON, // PROPERTIES // } // // Path: src/com/atsebak/ui5/autogeneration/UI5View.java // @NoArgsConstructor // public abstract class UI5View { // @Getter // private final CodeGenerator codeGenerator = new CodeGenerator(); // @Getter // private String extension; // // public UI5View(@NotNull String extension) { // this.extension = extension; // } // // /** // * Given the application type and the module path for generation // * @param appType // * @param controllerPath // * @return // */ // public String generateCode(AppType appType, String controllerPath) { // return codeGenerator.createViewCode(appType, controllerPath, extension); // } // } // // Path: src/com/atsebak/ui5/locale/UI5Bundle.java // public final class UI5Bundle { // // @NonNls // private static final String BUNDLE = "com.atsebak.ui5.locale.UI5Bundle"; // private static Reference<ResourceBundle> bundleReference; // // /** // * Private Constructor // */ // private UI5Bundle() { // } // // /** // * @param key // * @param params // * @return // */ // public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { // return BundleBase.message(getBundle(), key, params); // } // // /** // * @return // */ // private static ResourceBundle getBundle() { // ResourceBundle bundle = dereference(bundleReference); // if (bundle == null) { // bundle = ResourceBundle.getBundle(BUNDLE); // bundleReference = new SoftReference<ResourceBundle>(bundle); // } // return bundle; // } // // /** // * @param key The Key // * @return The Localized Text // */ // public static String getString(@PropertyKey(resourceBundle = BUNDLE) final String key) { // return getBundle().getString(key); // } // } // // Path: src/com/atsebak/ui5/util/UI5FileBuilder.java // public final class UI5FileBuilder { // // /** // * Creates a directory from a given name // * // * @param folder // * @param name // */ // public static void createDirectoryFromName(@NotNull File folder, @NotNull String name) { // File file = new File(folder, name); // file.mkdir(); // } // // /** // * Gets the module path based on the psidirectory passed // * // * @param psiDirectory // * @return // */ // public static String getModulePath(@NotNull PsiDirectory psiDirectory) { // Module module = ModuleUtilCore.findModuleForPsiElement(psiDirectory.getOriginalElement()); // if (module != null) { // String[] projectDircs; // String[] fileDircs; // String projectPath = module.getProject().getBasePath(); // String filePath = new File(psiDirectory.getVirtualFile().getPath()).getPath(); // assert projectPath != null; // projectDircs = projectPath.split(Pattern.quote(File.separator)); // fileDircs = filePath.split(Pattern.quote(File.separator)); // for (int i = 0; i < projectDircs.length; i++) { // if (projectDircs[i].equals(fileDircs[i])) { // fileDircs[i] = ""; // } // } // String codePath = ""; // for (int i = 0; i < fileDircs.length; i++) { // if (!fileDircs[i].isEmpty()) { // codePath += fileDircs[i]; // if (i != fileDircs.length - 1) { // codePath += "."; // } // } // // } // return codePath; // } // return ""; // } // // /** // * Get the interface implementation // * // * @param type // * @return // */ // public static UI5View getViewImplementation(@NotNull FileType type) { // switch (type) { // case JS: // return new JSView(); // case XML: // return new XMLView(); // case HTML: // return new HTMLView(); // case JSON: // return new JSONView(); // } // return null; // } // }
import com.atsebak.ui5.FileType; import com.atsebak.ui5.autogeneration.UI5View; import com.atsebak.ui5.locale.UI5Bundle; import com.atsebak.ui5.util.UI5FileBuilder; import com.intellij.ide.util.projectWizard.SettingsStep; import com.intellij.openapi.ui.ValidationInfo; import com.intellij.platform.WebProjectGenerator; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.util.Enumeration;
package com.atsebak.ui5.projectbuilder; public class ProjectPeer implements WebProjectGenerator.GeneratorPeer<UI5ProjectTemplateGenerator.UI5ProjectSettings> { private final java.util.List<WebProjectGenerator.SettingsStateListener> stateListeners = ContainerUtil.createLockFreeCopyOnWriteList(); private UI5ProjectTemplateGenerator.UI5ProjectSettings settings = new UI5ProjectTemplateGenerator.UI5ProjectSettings(); private ButtonGroup viewTypeButtonGroup = new ButtonGroup(); private JRadioButton javascriptRadioButton; private JRadioButton XMLRadioButton; private JRadioButton HTMLRadioButton; private JRadioButton JSONRadioButton; private JPanel panel; private JPanel viewPanel; public ProjectPeer() { viewTypeButtonGroup.add(javascriptRadioButton); viewTypeButtonGroup.add(XMLRadioButton); viewTypeButtonGroup.add(HTMLRadioButton); viewTypeButtonGroup.add(JSONRadioButton); } @NotNull @Override public JComponent getComponent() { return null; } @Override public void buildUI(@NotNull SettingsStep settingsStep) { settingsStep.addSettingsField(UI5Bundle.getString("view.type"), viewPanel); } @NotNull @Override public UI5ProjectTemplateGenerator.UI5ProjectSettings getSettings() { String viewType = getSelectedButton(viewTypeButtonGroup);
// Path: src/com/atsebak/ui5/FileType.java // public enum FileType { // JS, // XML, // HTML, // JSON, // PROPERTIES // } // // Path: src/com/atsebak/ui5/autogeneration/UI5View.java // @NoArgsConstructor // public abstract class UI5View { // @Getter // private final CodeGenerator codeGenerator = new CodeGenerator(); // @Getter // private String extension; // // public UI5View(@NotNull String extension) { // this.extension = extension; // } // // /** // * Given the application type and the module path for generation // * @param appType // * @param controllerPath // * @return // */ // public String generateCode(AppType appType, String controllerPath) { // return codeGenerator.createViewCode(appType, controllerPath, extension); // } // } // // Path: src/com/atsebak/ui5/locale/UI5Bundle.java // public final class UI5Bundle { // // @NonNls // private static final String BUNDLE = "com.atsebak.ui5.locale.UI5Bundle"; // private static Reference<ResourceBundle> bundleReference; // // /** // * Private Constructor // */ // private UI5Bundle() { // } // // /** // * @param key // * @param params // * @return // */ // public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { // return BundleBase.message(getBundle(), key, params); // } // // /** // * @return // */ // private static ResourceBundle getBundle() { // ResourceBundle bundle = dereference(bundleReference); // if (bundle == null) { // bundle = ResourceBundle.getBundle(BUNDLE); // bundleReference = new SoftReference<ResourceBundle>(bundle); // } // return bundle; // } // // /** // * @param key The Key // * @return The Localized Text // */ // public static String getString(@PropertyKey(resourceBundle = BUNDLE) final String key) { // return getBundle().getString(key); // } // } // // Path: src/com/atsebak/ui5/util/UI5FileBuilder.java // public final class UI5FileBuilder { // // /** // * Creates a directory from a given name // * // * @param folder // * @param name // */ // public static void createDirectoryFromName(@NotNull File folder, @NotNull String name) { // File file = new File(folder, name); // file.mkdir(); // } // // /** // * Gets the module path based on the psidirectory passed // * // * @param psiDirectory // * @return // */ // public static String getModulePath(@NotNull PsiDirectory psiDirectory) { // Module module = ModuleUtilCore.findModuleForPsiElement(psiDirectory.getOriginalElement()); // if (module != null) { // String[] projectDircs; // String[] fileDircs; // String projectPath = module.getProject().getBasePath(); // String filePath = new File(psiDirectory.getVirtualFile().getPath()).getPath(); // assert projectPath != null; // projectDircs = projectPath.split(Pattern.quote(File.separator)); // fileDircs = filePath.split(Pattern.quote(File.separator)); // for (int i = 0; i < projectDircs.length; i++) { // if (projectDircs[i].equals(fileDircs[i])) { // fileDircs[i] = ""; // } // } // String codePath = ""; // for (int i = 0; i < fileDircs.length; i++) { // if (!fileDircs[i].isEmpty()) { // codePath += fileDircs[i]; // if (i != fileDircs.length - 1) { // codePath += "."; // } // } // // } // return codePath; // } // return ""; // } // // /** // * Get the interface implementation // * // * @param type // * @return // */ // public static UI5View getViewImplementation(@NotNull FileType type) { // switch (type) { // case JS: // return new JSView(); // case XML: // return new XMLView(); // case HTML: // return new HTMLView(); // case JSON: // return new JSONView(); // } // return null; // } // } // Path: src/com/atsebak/ui5/projectbuilder/ProjectPeer.java import com.atsebak.ui5.FileType; import com.atsebak.ui5.autogeneration.UI5View; import com.atsebak.ui5.locale.UI5Bundle; import com.atsebak.ui5.util.UI5FileBuilder; import com.intellij.ide.util.projectWizard.SettingsStep; import com.intellij.openapi.ui.ValidationInfo; import com.intellij.platform.WebProjectGenerator; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.util.Enumeration; package com.atsebak.ui5.projectbuilder; public class ProjectPeer implements WebProjectGenerator.GeneratorPeer<UI5ProjectTemplateGenerator.UI5ProjectSettings> { private final java.util.List<WebProjectGenerator.SettingsStateListener> stateListeners = ContainerUtil.createLockFreeCopyOnWriteList(); private UI5ProjectTemplateGenerator.UI5ProjectSettings settings = new UI5ProjectTemplateGenerator.UI5ProjectSettings(); private ButtonGroup viewTypeButtonGroup = new ButtonGroup(); private JRadioButton javascriptRadioButton; private JRadioButton XMLRadioButton; private JRadioButton HTMLRadioButton; private JRadioButton JSONRadioButton; private JPanel panel; private JPanel viewPanel; public ProjectPeer() { viewTypeButtonGroup.add(javascriptRadioButton); viewTypeButtonGroup.add(XMLRadioButton); viewTypeButtonGroup.add(HTMLRadioButton); viewTypeButtonGroup.add(JSONRadioButton); } @NotNull @Override public JComponent getComponent() { return null; } @Override public void buildUI(@NotNull SettingsStep settingsStep) { settingsStep.addSettingsField(UI5Bundle.getString("view.type"), viewPanel); } @NotNull @Override public UI5ProjectTemplateGenerator.UI5ProjectSettings getSettings() { String viewType = getSelectedButton(viewTypeButtonGroup);
UI5View view = UI5FileBuilder.getViewImplementation(FileType.valueOf(viewType));
asebak/ui5-intellij-plugin
src/com/atsebak/ui5/projectbuilder/DesktopTemplateGenerator.java
// Path: src/com/atsebak/ui5/AppType.java // public enum AppType { // DESKTOP, // MOBILE // } // // Path: src/com/atsebak/ui5/locale/UI5Bundle.java // public final class UI5Bundle { // // @NonNls // private static final String BUNDLE = "com.atsebak.ui5.locale.UI5Bundle"; // private static Reference<ResourceBundle> bundleReference; // // /** // * Private Constructor // */ // private UI5Bundle() { // } // // /** // * @param key // * @param params // * @return // */ // public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { // return BundleBase.message(getBundle(), key, params); // } // // /** // * @return // */ // private static ResourceBundle getBundle() { // ResourceBundle bundle = dereference(bundleReference); // if (bundle == null) { // bundle = ResourceBundle.getBundle(BUNDLE); // bundleReference = new SoftReference<ResourceBundle>(bundle); // } // return bundle; // } // // /** // * @param key The Key // * @return The Localized Text // */ // public static String getString(@PropertyKey(resourceBundle = BUNDLE) final String key) { // return getBundle().getString(key); // } // }
import com.atsebak.ui5.AppType; import com.atsebak.ui5.locale.UI5Bundle; import com.intellij.icons.AllIcons; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import javax.swing.*;
package com.atsebak.ui5.projectbuilder; public class DesktopTemplateGenerator extends UI5ProjectTemplateGenerator { @Nls @NotNull @Override public String getName() {
// Path: src/com/atsebak/ui5/AppType.java // public enum AppType { // DESKTOP, // MOBILE // } // // Path: src/com/atsebak/ui5/locale/UI5Bundle.java // public final class UI5Bundle { // // @NonNls // private static final String BUNDLE = "com.atsebak.ui5.locale.UI5Bundle"; // private static Reference<ResourceBundle> bundleReference; // // /** // * Private Constructor // */ // private UI5Bundle() { // } // // /** // * @param key // * @param params // * @return // */ // public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { // return BundleBase.message(getBundle(), key, params); // } // // /** // * @return // */ // private static ResourceBundle getBundle() { // ResourceBundle bundle = dereference(bundleReference); // if (bundle == null) { // bundle = ResourceBundle.getBundle(BUNDLE); // bundleReference = new SoftReference<ResourceBundle>(bundle); // } // return bundle; // } // // /** // * @param key The Key // * @return The Localized Text // */ // public static String getString(@PropertyKey(resourceBundle = BUNDLE) final String key) { // return getBundle().getString(key); // } // } // Path: src/com/atsebak/ui5/projectbuilder/DesktopTemplateGenerator.java import com.atsebak.ui5.AppType; import com.atsebak.ui5.locale.UI5Bundle; import com.intellij.icons.AllIcons; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import javax.swing.*; package com.atsebak.ui5.projectbuilder; public class DesktopTemplateGenerator extends UI5ProjectTemplateGenerator { @Nls @NotNull @Override public String getName() {
return UI5Bundle.getString("desktop.app");
asebak/ui5-intellij-plugin
src/com/atsebak/ui5/projectbuilder/DesktopTemplateGenerator.java
// Path: src/com/atsebak/ui5/AppType.java // public enum AppType { // DESKTOP, // MOBILE // } // // Path: src/com/atsebak/ui5/locale/UI5Bundle.java // public final class UI5Bundle { // // @NonNls // private static final String BUNDLE = "com.atsebak.ui5.locale.UI5Bundle"; // private static Reference<ResourceBundle> bundleReference; // // /** // * Private Constructor // */ // private UI5Bundle() { // } // // /** // * @param key // * @param params // * @return // */ // public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { // return BundleBase.message(getBundle(), key, params); // } // // /** // * @return // */ // private static ResourceBundle getBundle() { // ResourceBundle bundle = dereference(bundleReference); // if (bundle == null) { // bundle = ResourceBundle.getBundle(BUNDLE); // bundleReference = new SoftReference<ResourceBundle>(bundle); // } // return bundle; // } // // /** // * @param key The Key // * @return The Localized Text // */ // public static String getString(@PropertyKey(resourceBundle = BUNDLE) final String key) { // return getBundle().getString(key); // } // }
import com.atsebak.ui5.AppType; import com.atsebak.ui5.locale.UI5Bundle; import com.intellij.icons.AllIcons; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import javax.swing.*;
package com.atsebak.ui5.projectbuilder; public class DesktopTemplateGenerator extends UI5ProjectTemplateGenerator { @Nls @NotNull @Override public String getName() { return UI5Bundle.getString("desktop.app"); } @NotNull @Override public String getDescription() { return UI5Bundle.getString("desktop.description"); } @Override public Icon getIcon() { return AllIcons.General.CreateNewProject; } @Override public void generateProject(@NotNull Project project, @NotNull VirtualFile virtualFile, @NotNull UI5ProjectSettings settings, @NotNull Module module) {
// Path: src/com/atsebak/ui5/AppType.java // public enum AppType { // DESKTOP, // MOBILE // } // // Path: src/com/atsebak/ui5/locale/UI5Bundle.java // public final class UI5Bundle { // // @NonNls // private static final String BUNDLE = "com.atsebak.ui5.locale.UI5Bundle"; // private static Reference<ResourceBundle> bundleReference; // // /** // * Private Constructor // */ // private UI5Bundle() { // } // // /** // * @param key // * @param params // * @return // */ // public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { // return BundleBase.message(getBundle(), key, params); // } // // /** // * @return // */ // private static ResourceBundle getBundle() { // ResourceBundle bundle = dereference(bundleReference); // if (bundle == null) { // bundle = ResourceBundle.getBundle(BUNDLE); // bundleReference = new SoftReference<ResourceBundle>(bundle); // } // return bundle; // } // // /** // * @param key The Key // * @return The Localized Text // */ // public static String getString(@PropertyKey(resourceBundle = BUNDLE) final String key) { // return getBundle().getString(key); // } // } // Path: src/com/atsebak/ui5/projectbuilder/DesktopTemplateGenerator.java import com.atsebak.ui5.AppType; import com.atsebak.ui5.locale.UI5Bundle; import com.intellij.icons.AllIcons; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import javax.swing.*; package com.atsebak.ui5.projectbuilder; public class DesktopTemplateGenerator extends UI5ProjectTemplateGenerator { @Nls @NotNull @Override public String getName() { return UI5Bundle.getString("desktop.app"); } @NotNull @Override public String getDescription() { return UI5Bundle.getString("desktop.description"); } @Override public Icon getIcon() { return AllIcons.General.CreateNewProject; } @Override public void generateProject(@NotNull Project project, @NotNull VirtualFile virtualFile, @NotNull UI5ProjectSettings settings, @NotNull Module module) {
settings.setLibrary(AppType.DESKTOP);
gocardless/gocardless-pro-java
src/main/java/com/gocardless/services/BillingRequestTemplateService.java
// Path: src/main/java/com/gocardless/resources/BillingRequestTemplate.java // public class BillingRequestTemplate { // private BillingRequestTemplate() { // // blank to prevent instantiation // } // // private String authorisationUrl; // private String createdAt; // private String id; // private String mandateRequestCurrency; // private Map<String, String> mandateRequestMetadata; // private String mandateRequestScheme; // private MandateRequestVerify mandateRequestVerify; // private Map<String, String> metadata; // private String name; // private Integer paymentRequestAmount; // private String paymentRequestCurrency; // private String paymentRequestDescription; // private Map<String, String> paymentRequestMetadata; // private String paymentRequestScheme; // private String redirectUri; // private String updatedAt; // // /** // * Permanent URL that customers can visit to allow them to complete a flow based on this // * template, before being returned to the `redirect_uri`. // */ // public String getAuthorisationUrl() { // return authorisationUrl; // } // // /** // * Fixed [timestamp](#api-usage-time-zones--dates), recording when this resource was created. // */ // public String getCreatedAt() { // return createdAt; // } // // /** // * Unique identifier, beginning with "BRT". // */ // public String getId() { // return id; // } // // /** // * [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217#Active_codes) currency code. // */ // public String getMandateRequestCurrency() { // return mandateRequestCurrency; // } // // /** // * Key-value store of custom data that will be applied to the mandate created when this request // * is fulfilled. Up to 3 keys are permitted, with key names up to 50 characters and values up to // * 500 characters. // */ // public Map<String, String> getMandateRequestMetadata() { // return mandateRequestMetadata; // } // // /** // * A Direct Debit scheme. Currently "ach", "bacs", "becs", "becs_nz", "betalingsservice", "pad" // * and "sepa_core" are supported. // */ // public String getMandateRequestScheme() { // return mandateRequestScheme; // } // // /** // * Verification preference for the mandate. One of: // * <ul> // * <li>`minimum`: only verify if absolutely required, such as when part of scheme rules</li> // * <li>`recommended`: in addition to minimum, use the GoCardless risk engine to decide an // * appropriate level of verification</li> // * <li>`when_available`: if verification mechanisms are available, use them</li> // * <li>`always`: as `when_available`, but fail to create the Billing Request if a mechanism // * isn't available</li> // * </ul> // * // * If not provided, the `recommended` level is chosen. // */ // public MandateRequestVerify getMandateRequestVerify() { // return mandateRequestVerify; // } // // /** // * Key-value store of custom data. Up to 3 keys are permitted, with key names up to 50 // * characters and values up to 500 characters. // */ // public Map<String, String> getMetadata() { // return metadata; // } // // /** // * Name for the template. Provides a friendly human name for the template, as it is shown in the // * dashboard. Must not exceed 255 characters. // */ // public String getName() { // return name; // } // // /** // * Amount in minor unit (e.g. pence in GBP, cents in EUR). // */ // public Integer getPaymentRequestAmount() { // return paymentRequestAmount; // } // // /** // * [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217#Active_codes) currency code. // */ // public String getPaymentRequestCurrency() { // return paymentRequestCurrency; // } // // /** // * A human-readable description of the payment. This will be displayed to the payer when // * authorising the billing request. // * // */ // public String getPaymentRequestDescription() { // return paymentRequestDescription; // } // // /** // * Key-value store of custom data that will be applied to the payment created when this request // * is fulfilled. Up to 3 keys are permitted, with key names up to 50 characters and values up to // * 500 characters. // */ // public Map<String, String> getPaymentRequestMetadata() { // return paymentRequestMetadata; // } // // /** // * A Direct Debit scheme. Currently "ach", "bacs", "becs", "becs_nz", "betalingsservice", "pad" // * and "sepa_core" are supported. // */ // public String getPaymentRequestScheme() { // return paymentRequestScheme; // } // // /** // * URL that the payer can be redirected to after completing the request flow. // */ // public String getRedirectUri() { // return redirectUri; // } // // /** // * Dynamic [timestamp](#api-usage-time-zones--dates) recording when this resource was last // * updated. // */ // public String getUpdatedAt() { // return updatedAt; // } // // public enum MandateRequestVerify { // @SerializedName("minimum") // MINIMUM, @SerializedName("recommended") // RECOMMENDED, @SerializedName("when_available") // WHEN_AVAILABLE, @SerializedName("always") // ALWAYS, @SerializedName("unknown") // UNKNOWN // } // }
import com.gocardless.http.*; import com.gocardless.resources.BillingRequestTemplate; import com.google.common.collect.ImmutableMap; import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; import java.util.HashMap; import java.util.List; import java.util.Map;
package com.gocardless.services; /** * Service class for working with billing request template resources. * * Billing Request Templates */ public class BillingRequestTemplateService { private final HttpClient httpClient; /** * Constructor. Users of this library should have no need to call this - an instance of this * class can be obtained by calling * {@link com.gocardless.GoCardlessClient#billingRequestTemplates() }. */ public BillingRequestTemplateService(HttpClient httpClient) { this.httpClient = httpClient; } /** * Returns a [cursor-paginated](#api-usage-cursor-pagination) list of your Billing Request * Templates. */
// Path: src/main/java/com/gocardless/resources/BillingRequestTemplate.java // public class BillingRequestTemplate { // private BillingRequestTemplate() { // // blank to prevent instantiation // } // // private String authorisationUrl; // private String createdAt; // private String id; // private String mandateRequestCurrency; // private Map<String, String> mandateRequestMetadata; // private String mandateRequestScheme; // private MandateRequestVerify mandateRequestVerify; // private Map<String, String> metadata; // private String name; // private Integer paymentRequestAmount; // private String paymentRequestCurrency; // private String paymentRequestDescription; // private Map<String, String> paymentRequestMetadata; // private String paymentRequestScheme; // private String redirectUri; // private String updatedAt; // // /** // * Permanent URL that customers can visit to allow them to complete a flow based on this // * template, before being returned to the `redirect_uri`. // */ // public String getAuthorisationUrl() { // return authorisationUrl; // } // // /** // * Fixed [timestamp](#api-usage-time-zones--dates), recording when this resource was created. // */ // public String getCreatedAt() { // return createdAt; // } // // /** // * Unique identifier, beginning with "BRT". // */ // public String getId() { // return id; // } // // /** // * [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217#Active_codes) currency code. // */ // public String getMandateRequestCurrency() { // return mandateRequestCurrency; // } // // /** // * Key-value store of custom data that will be applied to the mandate created when this request // * is fulfilled. Up to 3 keys are permitted, with key names up to 50 characters and values up to // * 500 characters. // */ // public Map<String, String> getMandateRequestMetadata() { // return mandateRequestMetadata; // } // // /** // * A Direct Debit scheme. Currently "ach", "bacs", "becs", "becs_nz", "betalingsservice", "pad" // * and "sepa_core" are supported. // */ // public String getMandateRequestScheme() { // return mandateRequestScheme; // } // // /** // * Verification preference for the mandate. One of: // * <ul> // * <li>`minimum`: only verify if absolutely required, such as when part of scheme rules</li> // * <li>`recommended`: in addition to minimum, use the GoCardless risk engine to decide an // * appropriate level of verification</li> // * <li>`when_available`: if verification mechanisms are available, use them</li> // * <li>`always`: as `when_available`, but fail to create the Billing Request if a mechanism // * isn't available</li> // * </ul> // * // * If not provided, the `recommended` level is chosen. // */ // public MandateRequestVerify getMandateRequestVerify() { // return mandateRequestVerify; // } // // /** // * Key-value store of custom data. Up to 3 keys are permitted, with key names up to 50 // * characters and values up to 500 characters. // */ // public Map<String, String> getMetadata() { // return metadata; // } // // /** // * Name for the template. Provides a friendly human name for the template, as it is shown in the // * dashboard. Must not exceed 255 characters. // */ // public String getName() { // return name; // } // // /** // * Amount in minor unit (e.g. pence in GBP, cents in EUR). // */ // public Integer getPaymentRequestAmount() { // return paymentRequestAmount; // } // // /** // * [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217#Active_codes) currency code. // */ // public String getPaymentRequestCurrency() { // return paymentRequestCurrency; // } // // /** // * A human-readable description of the payment. This will be displayed to the payer when // * authorising the billing request. // * // */ // public String getPaymentRequestDescription() { // return paymentRequestDescription; // } // // /** // * Key-value store of custom data that will be applied to the payment created when this request // * is fulfilled. Up to 3 keys are permitted, with key names up to 50 characters and values up to // * 500 characters. // */ // public Map<String, String> getPaymentRequestMetadata() { // return paymentRequestMetadata; // } // // /** // * A Direct Debit scheme. Currently "ach", "bacs", "becs", "becs_nz", "betalingsservice", "pad" // * and "sepa_core" are supported. // */ // public String getPaymentRequestScheme() { // return paymentRequestScheme; // } // // /** // * URL that the payer can be redirected to after completing the request flow. // */ // public String getRedirectUri() { // return redirectUri; // } // // /** // * Dynamic [timestamp](#api-usage-time-zones--dates) recording when this resource was last // * updated. // */ // public String getUpdatedAt() { // return updatedAt; // } // // public enum MandateRequestVerify { // @SerializedName("minimum") // MINIMUM, @SerializedName("recommended") // RECOMMENDED, @SerializedName("when_available") // WHEN_AVAILABLE, @SerializedName("always") // ALWAYS, @SerializedName("unknown") // UNKNOWN // } // } // Path: src/main/java/com/gocardless/services/BillingRequestTemplateService.java import com.gocardless.http.*; import com.gocardless.resources.BillingRequestTemplate; import com.google.common.collect.ImmutableMap; import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; import java.util.HashMap; import java.util.List; import java.util.Map; package com.gocardless.services; /** * Service class for working with billing request template resources. * * Billing Request Templates */ public class BillingRequestTemplateService { private final HttpClient httpClient; /** * Constructor. Users of this library should have no need to call this - an instance of this * class can be obtained by calling * {@link com.gocardless.GoCardlessClient#billingRequestTemplates() }. */ public BillingRequestTemplateService(HttpClient httpClient) { this.httpClient = httpClient; } /** * Returns a [cursor-paginated](#api-usage-cursor-pagination) list of your Billing Request * Templates. */
public BillingRequestTemplateListRequest<ListResponse<BillingRequestTemplate>> list() {
gocardless/gocardless-pro-java
src/test/java/com/gocardless/http/PaginatingIterableTest.java
// Path: src/test/java/com/gocardless/http/HttpTestUtil.java // public static class DummyItem { // public String stringField; // public int intField; // } // // Path: src/test/java/com/gocardless/http/ListRequestTest.java // static class DummyListRequest<S> extends ListRequest<S, DummyItem> { // private DummyListRequest(HttpClient httpClient, // ListRequestExecutor<S, DummyItem> executor) { // super(httpClient, executor); // } // // public DummyListRequest<S> withHeader(String headerName, String headerValue) { // this.addHeader(headerName, headerValue); // return this; // } // // @Override // protected ImmutableMap<String, Object> getQueryParams() { // return ImmutableMap.<String, Object>builder().putAll(super.getQueryParams()) // .put("id", "123").build(); // } // // @Override // protected String getPathTemplate() { // return "/dummy"; // } // // @Override // protected String getEnvelope() { // return "items"; // } // // @Override // protected TypeToken<List<DummyItem>> getTypeToken() { // return new TypeToken<List<DummyItem>>() {}; // } // // static DummyListRequest<ListResponse<DummyItem>> pageRequest(HttpClient httpClient) { // return new DummyListRequest<>(httpClient, ListRequest.<DummyItem>pagingExecutor()); // } // // static DummyListRequest<Iterable<DummyItem>> iterableRequest(HttpClient httpClient) { // return new DummyListRequest<>(httpClient, ListRequest.<DummyItem>iteratingExecutor()); // } // }
import static org.assertj.core.api.Assertions.assertThat; import com.gocardless.http.HttpTestUtil.DummyItem; import com.gocardless.http.ListRequestTest.DummyListRequest; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import java.util.List; import org.junit.Rule; import org.junit.Test;
package com.gocardless.http; public class PaginatingIterableTest { @Rule public final MockHttp http = new MockHttp(); @Test public void shouldIterateThroughPages() throws Exception { http.enqueueResponse(200, "fixtures/first-page.json"); http.enqueueResponse(200, "fixtures/last-page.json");
// Path: src/test/java/com/gocardless/http/HttpTestUtil.java // public static class DummyItem { // public String stringField; // public int intField; // } // // Path: src/test/java/com/gocardless/http/ListRequestTest.java // static class DummyListRequest<S> extends ListRequest<S, DummyItem> { // private DummyListRequest(HttpClient httpClient, // ListRequestExecutor<S, DummyItem> executor) { // super(httpClient, executor); // } // // public DummyListRequest<S> withHeader(String headerName, String headerValue) { // this.addHeader(headerName, headerValue); // return this; // } // // @Override // protected ImmutableMap<String, Object> getQueryParams() { // return ImmutableMap.<String, Object>builder().putAll(super.getQueryParams()) // .put("id", "123").build(); // } // // @Override // protected String getPathTemplate() { // return "/dummy"; // } // // @Override // protected String getEnvelope() { // return "items"; // } // // @Override // protected TypeToken<List<DummyItem>> getTypeToken() { // return new TypeToken<List<DummyItem>>() {}; // } // // static DummyListRequest<ListResponse<DummyItem>> pageRequest(HttpClient httpClient) { // return new DummyListRequest<>(httpClient, ListRequest.<DummyItem>pagingExecutor()); // } // // static DummyListRequest<Iterable<DummyItem>> iterableRequest(HttpClient httpClient) { // return new DummyListRequest<>(httpClient, ListRequest.<DummyItem>iteratingExecutor()); // } // } // Path: src/test/java/com/gocardless/http/PaginatingIterableTest.java import static org.assertj.core.api.Assertions.assertThat; import com.gocardless.http.HttpTestUtil.DummyItem; import com.gocardless.http.ListRequestTest.DummyListRequest; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import java.util.List; import org.junit.Rule; import org.junit.Test; package com.gocardless.http; public class PaginatingIterableTest { @Rule public final MockHttp http = new MockHttp(); @Test public void shouldIterateThroughPages() throws Exception { http.enqueueResponse(200, "fixtures/first-page.json"); http.enqueueResponse(200, "fixtures/last-page.json");
DummyListRequest<Iterable<DummyItem>> request =
gocardless/gocardless-pro-java
src/test/java/com/gocardless/http/PaginatingIterableTest.java
// Path: src/test/java/com/gocardless/http/HttpTestUtil.java // public static class DummyItem { // public String stringField; // public int intField; // } // // Path: src/test/java/com/gocardless/http/ListRequestTest.java // static class DummyListRequest<S> extends ListRequest<S, DummyItem> { // private DummyListRequest(HttpClient httpClient, // ListRequestExecutor<S, DummyItem> executor) { // super(httpClient, executor); // } // // public DummyListRequest<S> withHeader(String headerName, String headerValue) { // this.addHeader(headerName, headerValue); // return this; // } // // @Override // protected ImmutableMap<String, Object> getQueryParams() { // return ImmutableMap.<String, Object>builder().putAll(super.getQueryParams()) // .put("id", "123").build(); // } // // @Override // protected String getPathTemplate() { // return "/dummy"; // } // // @Override // protected String getEnvelope() { // return "items"; // } // // @Override // protected TypeToken<List<DummyItem>> getTypeToken() { // return new TypeToken<List<DummyItem>>() {}; // } // // static DummyListRequest<ListResponse<DummyItem>> pageRequest(HttpClient httpClient) { // return new DummyListRequest<>(httpClient, ListRequest.<DummyItem>pagingExecutor()); // } // // static DummyListRequest<Iterable<DummyItem>> iterableRequest(HttpClient httpClient) { // return new DummyListRequest<>(httpClient, ListRequest.<DummyItem>iteratingExecutor()); // } // }
import static org.assertj.core.api.Assertions.assertThat; import com.gocardless.http.HttpTestUtil.DummyItem; import com.gocardless.http.ListRequestTest.DummyListRequest; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import java.util.List; import org.junit.Rule; import org.junit.Test;
package com.gocardless.http; public class PaginatingIterableTest { @Rule public final MockHttp http = new MockHttp(); @Test public void shouldIterateThroughPages() throws Exception { http.enqueueResponse(200, "fixtures/first-page.json"); http.enqueueResponse(200, "fixtures/last-page.json");
// Path: src/test/java/com/gocardless/http/HttpTestUtil.java // public static class DummyItem { // public String stringField; // public int intField; // } // // Path: src/test/java/com/gocardless/http/ListRequestTest.java // static class DummyListRequest<S> extends ListRequest<S, DummyItem> { // private DummyListRequest(HttpClient httpClient, // ListRequestExecutor<S, DummyItem> executor) { // super(httpClient, executor); // } // // public DummyListRequest<S> withHeader(String headerName, String headerValue) { // this.addHeader(headerName, headerValue); // return this; // } // // @Override // protected ImmutableMap<String, Object> getQueryParams() { // return ImmutableMap.<String, Object>builder().putAll(super.getQueryParams()) // .put("id", "123").build(); // } // // @Override // protected String getPathTemplate() { // return "/dummy"; // } // // @Override // protected String getEnvelope() { // return "items"; // } // // @Override // protected TypeToken<List<DummyItem>> getTypeToken() { // return new TypeToken<List<DummyItem>>() {}; // } // // static DummyListRequest<ListResponse<DummyItem>> pageRequest(HttpClient httpClient) { // return new DummyListRequest<>(httpClient, ListRequest.<DummyItem>pagingExecutor()); // } // // static DummyListRequest<Iterable<DummyItem>> iterableRequest(HttpClient httpClient) { // return new DummyListRequest<>(httpClient, ListRequest.<DummyItem>iteratingExecutor()); // } // } // Path: src/test/java/com/gocardless/http/PaginatingIterableTest.java import static org.assertj.core.api.Assertions.assertThat; import com.gocardless.http.HttpTestUtil.DummyItem; import com.gocardless.http.ListRequestTest.DummyListRequest; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import java.util.List; import org.junit.Rule; import org.junit.Test; package com.gocardless.http; public class PaginatingIterableTest { @Rule public final MockHttp http = new MockHttp(); @Test public void shouldIterateThroughPages() throws Exception { http.enqueueResponse(200, "fixtures/first-page.json"); http.enqueueResponse(200, "fixtures/last-page.json");
DummyListRequest<Iterable<DummyItem>> request =
gocardless/gocardless-pro-java
src/main/java/com/gocardless/services/BillingRequestFlowService.java
// Path: src/main/java/com/gocardless/resources/BillingRequestFlow.java // public class BillingRequestFlow { // private BillingRequestFlow() { // // blank to prevent instantiation // } // // private String authorisationUrl; // private Boolean autoFulfil; // private String createdAt; // private String exitUri; // private String expiresAt; // private String id; // private Links links; // private Boolean lockBankAccount; // private Boolean lockCustomerDetails; // private String redirectUri; // private String sessionToken; // // /** // * URL for a GC-controlled flow which will allow the payer to fulfil the billing request // */ // public String getAuthorisationUrl() { // return authorisationUrl; // } // // /** // * (Experimental feature) Fulfil the Billing Request on completion of the flow (true by // * default). Disabling the auto_fulfil is not allowed currently. // */ // public Boolean getAutoFulfil() { // return autoFulfil; // } // // /** // * Timestamp when the flow was created // */ // public String getCreatedAt() { // return createdAt; // } // // /** // * URL that the payer can be taken to if there isn't a way to progress ahead in flow. // */ // public String getExitUri() { // return exitUri; // } // // /** // * Timestamp when the flow will expire. Each flow currently lasts for 7 days. // */ // public String getExpiresAt() { // return expiresAt; // } // // /** // * Unique identifier, beginning with "BRF". // */ // public String getId() { // return id; // } // // public Links getLinks() { // return links; // } // // /** // * If true, the payer will not be able to change their bank account within the flow. If the // * bank_account details are collected as part of bank_authorisation then GC will set this value // * to true mid flow // */ // public Boolean getLockBankAccount() { // return lockBankAccount; // } // // /** // * If true, the payer will not be able to edit their customer details within the flow. If the // * customer details are collected as part of bank_authorisation then GC will set this value to // * true mid flow // */ // public Boolean getLockCustomerDetails() { // return lockCustomerDetails; // } // // /** // * URL that the payer can be redirected to after completing the request flow. // */ // public String getRedirectUri() { // return redirectUri; // } // // /** // * Session token populated when responding to the initalise action // */ // public String getSessionToken() { // return sessionToken; // } // // public static class Links { // private Links() { // // blank to prevent instantiation // } // // private String billingRequest; // // /** // * ID of the [billing request](#billing-requests-billing-requests) against which this flow // * was created. // */ // public String getBillingRequest() { // return billingRequest; // } // } // }
import com.gocardless.http.*; import com.gocardless.resources.BillingRequestFlow; import com.google.common.collect.ImmutableMap; import java.util.Map;
package com.gocardless.services; /** * Service class for working with billing request flow resources. * * Billing Request Flows can be created to enable a payer to authorise a payment created for a * scheme with strong payer authorisation (such as open banking single payments). */ public class BillingRequestFlowService { private final HttpClient httpClient; /** * Constructor. Users of this library should have no need to call this - an instance of this * class can be obtained by calling * {@link com.gocardless.GoCardlessClient#billingRequestFlows() }. */ public BillingRequestFlowService(HttpClient httpClient) { this.httpClient = httpClient; } /** * Creates a new billing request flow. */ public BillingRequestFlowCreateRequest create() { return new BillingRequestFlowCreateRequest(httpClient); } /** * Returns the flow having generated a fresh session token which can be used to power * integrations that manipulate the flow. */ public BillingRequestFlowInitialiseRequest initialise(String identity) { return new BillingRequestFlowInitialiseRequest(httpClient, identity); } /** * Request class for {@link BillingRequestFlowService#create }. * * Creates a new billing request flow. */ public static final class BillingRequestFlowCreateRequest
// Path: src/main/java/com/gocardless/resources/BillingRequestFlow.java // public class BillingRequestFlow { // private BillingRequestFlow() { // // blank to prevent instantiation // } // // private String authorisationUrl; // private Boolean autoFulfil; // private String createdAt; // private String exitUri; // private String expiresAt; // private String id; // private Links links; // private Boolean lockBankAccount; // private Boolean lockCustomerDetails; // private String redirectUri; // private String sessionToken; // // /** // * URL for a GC-controlled flow which will allow the payer to fulfil the billing request // */ // public String getAuthorisationUrl() { // return authorisationUrl; // } // // /** // * (Experimental feature) Fulfil the Billing Request on completion of the flow (true by // * default). Disabling the auto_fulfil is not allowed currently. // */ // public Boolean getAutoFulfil() { // return autoFulfil; // } // // /** // * Timestamp when the flow was created // */ // public String getCreatedAt() { // return createdAt; // } // // /** // * URL that the payer can be taken to if there isn't a way to progress ahead in flow. // */ // public String getExitUri() { // return exitUri; // } // // /** // * Timestamp when the flow will expire. Each flow currently lasts for 7 days. // */ // public String getExpiresAt() { // return expiresAt; // } // // /** // * Unique identifier, beginning with "BRF". // */ // public String getId() { // return id; // } // // public Links getLinks() { // return links; // } // // /** // * If true, the payer will not be able to change their bank account within the flow. If the // * bank_account details are collected as part of bank_authorisation then GC will set this value // * to true mid flow // */ // public Boolean getLockBankAccount() { // return lockBankAccount; // } // // /** // * If true, the payer will not be able to edit their customer details within the flow. If the // * customer details are collected as part of bank_authorisation then GC will set this value to // * true mid flow // */ // public Boolean getLockCustomerDetails() { // return lockCustomerDetails; // } // // /** // * URL that the payer can be redirected to after completing the request flow. // */ // public String getRedirectUri() { // return redirectUri; // } // // /** // * Session token populated when responding to the initalise action // */ // public String getSessionToken() { // return sessionToken; // } // // public static class Links { // private Links() { // // blank to prevent instantiation // } // // private String billingRequest; // // /** // * ID of the [billing request](#billing-requests-billing-requests) against which this flow // * was created. // */ // public String getBillingRequest() { // return billingRequest; // } // } // } // Path: src/main/java/com/gocardless/services/BillingRequestFlowService.java import com.gocardless.http.*; import com.gocardless.resources.BillingRequestFlow; import com.google.common.collect.ImmutableMap; import java.util.Map; package com.gocardless.services; /** * Service class for working with billing request flow resources. * * Billing Request Flows can be created to enable a payer to authorise a payment created for a * scheme with strong payer authorisation (such as open banking single payments). */ public class BillingRequestFlowService { private final HttpClient httpClient; /** * Constructor. Users of this library should have no need to call this - an instance of this * class can be obtained by calling * {@link com.gocardless.GoCardlessClient#billingRequestFlows() }. */ public BillingRequestFlowService(HttpClient httpClient) { this.httpClient = httpClient; } /** * Creates a new billing request flow. */ public BillingRequestFlowCreateRequest create() { return new BillingRequestFlowCreateRequest(httpClient); } /** * Returns the flow having generated a fresh session token which can be used to power * integrations that manipulate the flow. */ public BillingRequestFlowInitialiseRequest initialise(String identity) { return new BillingRequestFlowInitialiseRequest(httpClient, identity); } /** * Request class for {@link BillingRequestFlowService#create }. * * Creates a new billing request flow. */ public static final class BillingRequestFlowCreateRequest
extends PostRequest<BillingRequestFlow> {
gocardless/gocardless-pro-java
src/main/java/com/gocardless/services/MandatePdfService.java
// Path: src/main/java/com/gocardless/resources/MandatePdf.java // public class MandatePdf { // private MandatePdf() { // // blank to prevent instantiation // } // // private String expiresAt; // private String url; // // /** // * The date and time at which the `url` will expire (10 minutes after the original request). // */ // public String getExpiresAt() { // return expiresAt; // } // // /** // * The URL at which this mandate PDF can be viewed until it expires at the date and time // * specified by `expires_at`. You should not store this URL or rely on its structure remaining // * the same. // */ // public String getUrl() { // return url; // } // }
import com.gocardless.http.*; import com.gocardless.resources.MandatePdf; import com.google.gson.annotations.SerializedName;
package com.gocardless.services; /** * Service class for working with mandate pdf resources. * * Mandate PDFs allow you to easily display [scheme-rules * compliant](#appendix-compliance-requirements) Direct Debit mandates to your customers. */ public class MandatePdfService { private final HttpClient httpClient; /** * Constructor. Users of this library should have no need to call this - an instance of this * class can be obtained by calling {@link com.gocardless.GoCardlessClient#mandatePdfs() }. */ public MandatePdfService(HttpClient httpClient) { this.httpClient = httpClient; } /** * Generates a PDF mandate and returns its temporary URL. * * Customer and bank account details can be left blank (for a blank mandate), provided manually, * or inferred from the ID of an existing [mandate](#core-endpoints-mandates). * * By default, we'll generate PDF mandates in English. * * To generate a PDF mandate in another language, set the `Accept-Language` header when creating * the PDF mandate to the relevant [ISO * 639-1](http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) language code supported for the * scheme. * * | Scheme | Supported languages | | :--------------- | * :------------------------------------------------------------------------------------------------------------------------------------------- * | | ACH | English (`en`) | | Autogiro | English (`en`), Swedish (`sv`) | | Bacs | English * (`en`) | | BECS | English (`en`) | | BECS NZ | English (`en`) | | Betalingsservice | Danish * (`da`), English (`en`) | | PAD | English (`en`) | | SEPA Core | Danish (`da`), Dutch (`nl`), * English (`en`), French (`fr`), German (`de`), Italian (`it`), Portuguese (`pt`), Spanish * (`es`), Swedish (`sv`) | */ public MandatePdfCreateRequest create() { return new MandatePdfCreateRequest(httpClient); } /** * Request class for {@link MandatePdfService#create }. * * Generates a PDF mandate and returns its temporary URL. * * Customer and bank account details can be left blank (for a blank mandate), provided manually, * or inferred from the ID of an existing [mandate](#core-endpoints-mandates). * * By default, we'll generate PDF mandates in English. * * To generate a PDF mandate in another language, set the `Accept-Language` header when creating * the PDF mandate to the relevant [ISO * 639-1](http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) language code supported for the * scheme. * * | Scheme | Supported languages | | :--------------- | * :------------------------------------------------------------------------------------------------------------------------------------------- * | | ACH | English (`en`) | | Autogiro | English (`en`), Swedish (`sv`) | | Bacs | English * (`en`) | | BECS | English (`en`) | | BECS NZ | English (`en`) | | Betalingsservice | Danish * (`da`), English (`en`) | | PAD | English (`en`) | | SEPA Core | Danish (`da`), Dutch (`nl`), * English (`en`), French (`fr`), German (`de`), Italian (`it`), Portuguese (`pt`), Spanish * (`es`), Swedish (`sv`) | */
// Path: src/main/java/com/gocardless/resources/MandatePdf.java // public class MandatePdf { // private MandatePdf() { // // blank to prevent instantiation // } // // private String expiresAt; // private String url; // // /** // * The date and time at which the `url` will expire (10 minutes after the original request). // */ // public String getExpiresAt() { // return expiresAt; // } // // /** // * The URL at which this mandate PDF can be viewed until it expires at the date and time // * specified by `expires_at`. You should not store this URL or rely on its structure remaining // * the same. // */ // public String getUrl() { // return url; // } // } // Path: src/main/java/com/gocardless/services/MandatePdfService.java import com.gocardless.http.*; import com.gocardless.resources.MandatePdf; import com.google.gson.annotations.SerializedName; package com.gocardless.services; /** * Service class for working with mandate pdf resources. * * Mandate PDFs allow you to easily display [scheme-rules * compliant](#appendix-compliance-requirements) Direct Debit mandates to your customers. */ public class MandatePdfService { private final HttpClient httpClient; /** * Constructor. Users of this library should have no need to call this - an instance of this * class can be obtained by calling {@link com.gocardless.GoCardlessClient#mandatePdfs() }. */ public MandatePdfService(HttpClient httpClient) { this.httpClient = httpClient; } /** * Generates a PDF mandate and returns its temporary URL. * * Customer and bank account details can be left blank (for a blank mandate), provided manually, * or inferred from the ID of an existing [mandate](#core-endpoints-mandates). * * By default, we'll generate PDF mandates in English. * * To generate a PDF mandate in another language, set the `Accept-Language` header when creating * the PDF mandate to the relevant [ISO * 639-1](http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) language code supported for the * scheme. * * | Scheme | Supported languages | | :--------------- | * :------------------------------------------------------------------------------------------------------------------------------------------- * | | ACH | English (`en`) | | Autogiro | English (`en`), Swedish (`sv`) | | Bacs | English * (`en`) | | BECS | English (`en`) | | BECS NZ | English (`en`) | | Betalingsservice | Danish * (`da`), English (`en`) | | PAD | English (`en`) | | SEPA Core | Danish (`da`), Dutch (`nl`), * English (`en`), French (`fr`), German (`de`), Italian (`it`), Portuguese (`pt`), Spanish * (`es`), Swedish (`sv`) | */ public MandatePdfCreateRequest create() { return new MandatePdfCreateRequest(httpClient); } /** * Request class for {@link MandatePdfService#create }. * * Generates a PDF mandate and returns its temporary URL. * * Customer and bank account details can be left blank (for a blank mandate), provided manually, * or inferred from the ID of an existing [mandate](#core-endpoints-mandates). * * By default, we'll generate PDF mandates in English. * * To generate a PDF mandate in another language, set the `Accept-Language` header when creating * the PDF mandate to the relevant [ISO * 639-1](http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) language code supported for the * scheme. * * | Scheme | Supported languages | | :--------------- | * :------------------------------------------------------------------------------------------------------------------------------------------- * | | ACH | English (`en`) | | Autogiro | English (`en`), Swedish (`sv`) | | Bacs | English * (`en`) | | BECS | English (`en`) | | BECS NZ | English (`en`) | | Betalingsservice | Danish * (`da`), English (`en`) | | PAD | English (`en`) | | SEPA Core | Danish (`da`), Dutch (`nl`), * English (`en`), French (`fr`), German (`de`), Italian (`it`), Portuguese (`pt`), Spanish * (`es`), Swedish (`sv`) | */
public static final class MandatePdfCreateRequest extends PostRequest<MandatePdf> {
gocardless/gocardless-pro-java
src/main/java/com/gocardless/services/InstitutionService.java
// Path: src/main/java/com/gocardless/resources/Institution.java // public class Institution { // private Institution() { // // blank to prevent instantiation // } // // private String countryCode; // private String iconUrl; // private String id; // private String logoUrl; // private String name; // // /** // * [ISO // * 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements) // * alpha-2 code. The country code of the institution. // */ // public String getCountryCode() { // return countryCode; // } // // /** // * A URL pointing to the icon for this institution // */ // public String getIconUrl() { // return iconUrl; // } // // /** // * The unique identifier for this institution // */ // public String getId() { // return id; // } // // /** // * A URL pointing to the logo for this institution // */ // public String getLogoUrl() { // return logoUrl; // } // // /** // * A human readable name for this institution // */ // public String getName() { // return name; // } // }
import com.gocardless.http.*; import com.gocardless.resources.Institution; import com.google.common.collect.ImmutableMap; import com.google.gson.reflect.TypeToken; import java.util.List; import java.util.Map;
package com.gocardless.services; /** * Service class for working with institution resources. * * Institutions that are supported when creating [Bank * Authorisations](#billing-requests-bank-authorisations). */ public class InstitutionService { private final HttpClient httpClient; /** * Constructor. Users of this library should have no need to call this - an instance of this * class can be obtained by calling {@link com.gocardless.GoCardlessClient#institutions() }. */ public InstitutionService(HttpClient httpClient) { this.httpClient = httpClient; } /** * Returns a list of all supported institutions. */
// Path: src/main/java/com/gocardless/resources/Institution.java // public class Institution { // private Institution() { // // blank to prevent instantiation // } // // private String countryCode; // private String iconUrl; // private String id; // private String logoUrl; // private String name; // // /** // * [ISO // * 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements) // * alpha-2 code. The country code of the institution. // */ // public String getCountryCode() { // return countryCode; // } // // /** // * A URL pointing to the icon for this institution // */ // public String getIconUrl() { // return iconUrl; // } // // /** // * The unique identifier for this institution // */ // public String getId() { // return id; // } // // /** // * A URL pointing to the logo for this institution // */ // public String getLogoUrl() { // return logoUrl; // } // // /** // * A human readable name for this institution // */ // public String getName() { // return name; // } // } // Path: src/main/java/com/gocardless/services/InstitutionService.java import com.gocardless.http.*; import com.gocardless.resources.Institution; import com.google.common.collect.ImmutableMap; import com.google.gson.reflect.TypeToken; import java.util.List; import java.util.Map; package com.gocardless.services; /** * Service class for working with institution resources. * * Institutions that are supported when creating [Bank * Authorisations](#billing-requests-bank-authorisations). */ public class InstitutionService { private final HttpClient httpClient; /** * Constructor. Users of this library should have no need to call this - an instance of this * class can be obtained by calling {@link com.gocardless.GoCardlessClient#institutions() }. */ public InstitutionService(HttpClient httpClient) { this.httpClient = httpClient; } /** * Returns a list of all supported institutions. */
public InstitutionListRequest<ListResponse<Institution>> list() {
gocardless/gocardless-pro-java
src/main/java/com/gocardless/http/IdempotentPostRequest.java
// Path: src/main/java/com/gocardless/errors/ApiError.java // public class ApiError { // private static final Joiner JOINER = Joiner.on(" ").skipNulls(); // private final String message; // private final String reason; // private final String field; // private final String requestPointer; // private final Map<String, String> links; // // private ApiError(String message, String reason, String field, String requestPointer, // Map<String, String> links) { // this.message = message; // this.reason = reason; // this.field = field; // this.requestPointer = requestPointer; // this.links = links; // } // // /** // * Returns a message describing the problem. // */ // public String getMessage() { // return message; // } // // /** // * Returns a key identifying the reason for this error. // */ // public String getReason() { // return reason; // } // // /** // * Returns the field that this error applies to. // */ // public String getField() { // return field; // } // // /** // * Returns the request pointer, indicating the exact field of the request that triggered the // * validation error // */ // public String getRequestPointer() { // return requestPointer; // } // // /** // * Returns the IDs of related objects. // */ // public Map<String, String> getLinks() { // if (links == null) { // return ImmutableMap.of(); // } // return ImmutableMap.copyOf(links); // } // // @Override // public String toString() { // return JOINER.join(field, message); // } // } // // Path: src/main/java/com/gocardless/errors/InvalidStateException.java // public class InvalidStateException extends GoCardlessApiException { // InvalidStateException(ApiErrorResponse error) { // super(error); // } // }
import com.gocardless.errors.ApiError; import com.gocardless.errors.InvalidStateException; import com.google.common.base.Optional; import com.google.common.base.Predicate; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import java.util.UUID;
package com.gocardless.http; public abstract class IdempotentPostRequest<T> extends PostRequest<T> { private static final Predicate<ApiError> CONFLICT_ERROR = new Predicate<ApiError>() { @Override public boolean apply(ApiError error) { return error.getReason().equals("idempotent_creation_conflict"); } }; private transient String idempotencyKey; protected IdempotentPostRequest(HttpClient httpClient) { super(httpClient); } /** * Executes this request. * * Returns the response entity. * * @throws com.gocardless.GoCardlessException */ @Override public T execute() { try { return getHttpClient().executeWithRetries(this);
// Path: src/main/java/com/gocardless/errors/ApiError.java // public class ApiError { // private static final Joiner JOINER = Joiner.on(" ").skipNulls(); // private final String message; // private final String reason; // private final String field; // private final String requestPointer; // private final Map<String, String> links; // // private ApiError(String message, String reason, String field, String requestPointer, // Map<String, String> links) { // this.message = message; // this.reason = reason; // this.field = field; // this.requestPointer = requestPointer; // this.links = links; // } // // /** // * Returns a message describing the problem. // */ // public String getMessage() { // return message; // } // // /** // * Returns a key identifying the reason for this error. // */ // public String getReason() { // return reason; // } // // /** // * Returns the field that this error applies to. // */ // public String getField() { // return field; // } // // /** // * Returns the request pointer, indicating the exact field of the request that triggered the // * validation error // */ // public String getRequestPointer() { // return requestPointer; // } // // /** // * Returns the IDs of related objects. // */ // public Map<String, String> getLinks() { // if (links == null) { // return ImmutableMap.of(); // } // return ImmutableMap.copyOf(links); // } // // @Override // public String toString() { // return JOINER.join(field, message); // } // } // // Path: src/main/java/com/gocardless/errors/InvalidStateException.java // public class InvalidStateException extends GoCardlessApiException { // InvalidStateException(ApiErrorResponse error) { // super(error); // } // } // Path: src/main/java/com/gocardless/http/IdempotentPostRequest.java import com.gocardless.errors.ApiError; import com.gocardless.errors.InvalidStateException; import com.google.common.base.Optional; import com.google.common.base.Predicate; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import java.util.UUID; package com.gocardless.http; public abstract class IdempotentPostRequest<T> extends PostRequest<T> { private static final Predicate<ApiError> CONFLICT_ERROR = new Predicate<ApiError>() { @Override public boolean apply(ApiError error) { return error.getReason().equals("idempotent_creation_conflict"); } }; private transient String idempotencyKey; protected IdempotentPostRequest(HttpClient httpClient) { super(httpClient); } /** * Executes this request. * * Returns the response entity. * * @throws com.gocardless.GoCardlessException */ @Override public T execute() { try { return getHttpClient().executeWithRetries(this);
} catch (InvalidStateException e) {
gocardless/gocardless-pro-java
src/test/java/com/gocardless/http/PostRequestTest.java
// Path: src/test/java/com/gocardless/http/HttpTestUtil.java // public static class DummyItem { // public String stringField; // public int intField; // }
import static org.assertj.core.api.Assertions.assertThat; import com.gocardless.http.HttpTestUtil.DummyItem; import com.google.common.collect.ImmutableMap; import org.junit.Rule; import org.junit.Test;
package com.gocardless.http; public class PostRequestTest { @Rule public final MockHttp http = new MockHttp(); @Test public void shouldPerformPostRequest() throws Exception { http.enqueueResponse(200, "fixtures/single.json");
// Path: src/test/java/com/gocardless/http/HttpTestUtil.java // public static class DummyItem { // public String stringField; // public int intField; // } // Path: src/test/java/com/gocardless/http/PostRequestTest.java import static org.assertj.core.api.Assertions.assertThat; import com.gocardless.http.HttpTestUtil.DummyItem; import com.google.common.collect.ImmutableMap; import org.junit.Rule; import org.junit.Test; package com.gocardless.http; public class PostRequestTest { @Rule public final MockHttp http = new MockHttp(); @Test public void shouldPerformPostRequest() throws Exception { http.enqueueResponse(200, "fixtures/single.json");
DummyItem result = new DummyPostRequest().execute();
gocardless/gocardless-pro-java
src/test/java/com/gocardless/http/GetRequestTest.java
// Path: src/main/java/com/gocardless/errors/InvalidApiUsageException.java // public class InvalidApiUsageException extends GoCardlessApiException { // InvalidApiUsageException(ApiErrorResponse error) { // super(error); // } // } // // Path: src/test/java/com/gocardless/http/HttpTestUtil.java // public static class DummyItem { // public String stringField; // public int intField; // }
import static org.assertj.core.api.Assertions.assertThat; import com.gocardless.errors.InvalidApiUsageException; import com.gocardless.http.HttpTestUtil.DummyItem; import com.google.common.collect.ImmutableMap; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException;
package com.gocardless.http; public class GetRequestTest { @Rule public final MockHttp http = new MockHttp(); @Rule public final ExpectedException exception = ExpectedException.none(); @Test public void shouldPerformGetRequest() throws Exception { http.enqueueResponse(200, "fixtures/single.json");
// Path: src/main/java/com/gocardless/errors/InvalidApiUsageException.java // public class InvalidApiUsageException extends GoCardlessApiException { // InvalidApiUsageException(ApiErrorResponse error) { // super(error); // } // } // // Path: src/test/java/com/gocardless/http/HttpTestUtil.java // public static class DummyItem { // public String stringField; // public int intField; // } // Path: src/test/java/com/gocardless/http/GetRequestTest.java import static org.assertj.core.api.Assertions.assertThat; import com.gocardless.errors.InvalidApiUsageException; import com.gocardless.http.HttpTestUtil.DummyItem; import com.google.common.collect.ImmutableMap; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; package com.gocardless.http; public class GetRequestTest { @Rule public final MockHttp http = new MockHttp(); @Rule public final ExpectedException exception = ExpectedException.none(); @Test public void shouldPerformGetRequest() throws Exception { http.enqueueResponse(200, "fixtures/single.json");
DummyItem result = new DummyGetRequest().execute();
gocardless/gocardless-pro-java
src/test/java/com/gocardless/http/GetRequestTest.java
// Path: src/main/java/com/gocardless/errors/InvalidApiUsageException.java // public class InvalidApiUsageException extends GoCardlessApiException { // InvalidApiUsageException(ApiErrorResponse error) { // super(error); // } // } // // Path: src/test/java/com/gocardless/http/HttpTestUtil.java // public static class DummyItem { // public String stringField; // public int intField; // }
import static org.assertj.core.api.Assertions.assertThat; import com.gocardless.errors.InvalidApiUsageException; import com.gocardless.http.HttpTestUtil.DummyItem; import com.google.common.collect.ImmutableMap; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException;
package com.gocardless.http; public class GetRequestTest { @Rule public final MockHttp http = new MockHttp(); @Rule public final ExpectedException exception = ExpectedException.none(); @Test public void shouldPerformGetRequest() throws Exception { http.enqueueResponse(200, "fixtures/single.json"); DummyItem result = new DummyGetRequest().execute(); assertThat(result.stringField).isEqualTo("foo"); assertThat(result.intField).isEqualTo(123); http.assertRequestMade("GET", "/dummy/123", ImmutableMap.of("Authorization", "Bearer token")); } @Test public void shouldPerformWrappedGetRequest() throws Exception { http.enqueueResponse(200, "fixtures/single.json", ImmutableMap.of("foo", "bar")); ApiResponse<DummyItem> result = new DummyGetRequest().withHeader("Accept-Language", "fr-FR").executeWrapped(); assertThat(result.getStatusCode()).isEqualTo(200); assertThat(result.getHeaders().get("foo")).containsExactly("bar"); assertThat(result.getResource().stringField).isEqualTo("foo"); assertThat(result.getResource().intField).isEqualTo(123); http.assertRequestMade("GET", "/dummy/123", ImmutableMap.of("Authorization", "Bearer token", "Accept-Language", "fr-FR")); } @Test public void shouldThrowOnApiError() throws Exception { http.enqueueResponse(400, "fixtures/invalid_api_usage.json");
// Path: src/main/java/com/gocardless/errors/InvalidApiUsageException.java // public class InvalidApiUsageException extends GoCardlessApiException { // InvalidApiUsageException(ApiErrorResponse error) { // super(error); // } // } // // Path: src/test/java/com/gocardless/http/HttpTestUtil.java // public static class DummyItem { // public String stringField; // public int intField; // } // Path: src/test/java/com/gocardless/http/GetRequestTest.java import static org.assertj.core.api.Assertions.assertThat; import com.gocardless.errors.InvalidApiUsageException; import com.gocardless.http.HttpTestUtil.DummyItem; import com.google.common.collect.ImmutableMap; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; package com.gocardless.http; public class GetRequestTest { @Rule public final MockHttp http = new MockHttp(); @Rule public final ExpectedException exception = ExpectedException.none(); @Test public void shouldPerformGetRequest() throws Exception { http.enqueueResponse(200, "fixtures/single.json"); DummyItem result = new DummyGetRequest().execute(); assertThat(result.stringField).isEqualTo("foo"); assertThat(result.intField).isEqualTo(123); http.assertRequestMade("GET", "/dummy/123", ImmutableMap.of("Authorization", "Bearer token")); } @Test public void shouldPerformWrappedGetRequest() throws Exception { http.enqueueResponse(200, "fixtures/single.json", ImmutableMap.of("foo", "bar")); ApiResponse<DummyItem> result = new DummyGetRequest().withHeader("Accept-Language", "fr-FR").executeWrapped(); assertThat(result.getStatusCode()).isEqualTo(200); assertThat(result.getHeaders().get("foo")).containsExactly("bar"); assertThat(result.getResource().stringField).isEqualTo("foo"); assertThat(result.getResource().intField).isEqualTo(123); http.assertRequestMade("GET", "/dummy/123", ImmutableMap.of("Authorization", "Bearer token", "Accept-Language", "fr-FR")); } @Test public void shouldThrowOnApiError() throws Exception { http.enqueueResponse(400, "fixtures/invalid_api_usage.json");
exception.expect(InvalidApiUsageException.class);
gocardless/gocardless-pro-java
src/test/java/com/gocardless/http/RequestWriterTest.java
// Path: src/test/java/com/gocardless/http/HttpTestUtil.java // public static boolean jsonMatchesFixture(String actual, String fixturePath) throws IOException { // JsonParser parser = new JsonParser(); // String expectedJson = Resources.toString(getResource(fixturePath), UTF_8); // JsonElement result = parser.parse(actual); // JsonElement expected = parser.parse(expectedJson); // return result.equals(expected); // }
import static com.gocardless.http.HttpTestUtil.jsonMatchesFixture; import static org.assertj.core.api.Assertions.assertThat; import java.io.IOException; import org.junit.Before; import org.junit.Test;
package com.gocardless.http; public class RequestWriterTest { private RequestWriter writer; @Before public void setUp() { writer = new RequestWriter(GsonFactory.build()); } @Test public void shouldWriteRequestAsJson() throws IOException { String result = writer.write(new DummyRequest(), "items");
// Path: src/test/java/com/gocardless/http/HttpTestUtil.java // public static boolean jsonMatchesFixture(String actual, String fixturePath) throws IOException { // JsonParser parser = new JsonParser(); // String expectedJson = Resources.toString(getResource(fixturePath), UTF_8); // JsonElement result = parser.parse(actual); // JsonElement expected = parser.parse(expectedJson); // return result.equals(expected); // } // Path: src/test/java/com/gocardless/http/RequestWriterTest.java import static com.gocardless.http.HttpTestUtil.jsonMatchesFixture; import static org.assertj.core.api.Assertions.assertThat; import java.io.IOException; import org.junit.Before; import org.junit.Test; package com.gocardless.http; public class RequestWriterTest { private RequestWriter writer; @Before public void setUp() { writer = new RequestWriter(GsonFactory.build()); } @Test public void shouldWriteRequestAsJson() throws IOException { String result = writer.write(new DummyRequest(), "items");
assertThat(jsonMatchesFixture(result, "fixtures/single.json")).isTrue();
gocardless/gocardless-pro-java
src/main/java/com/gocardless/services/CustomerService.java
// Path: src/main/java/com/gocardless/resources/Customer.java // public class Customer { // private Customer() { // // blank to prevent instantiation // } // // private String addressLine1; // private String addressLine2; // private String addressLine3; // private String city; // private String companyName; // private String countryCode; // private String createdAt; // private String danishIdentityNumber; // private String email; // private String familyName; // private String givenName; // private String id; // private String language; // private Map<String, String> metadata; // private String phoneNumber; // private String postalCode; // private String region; // private String swedishIdentityNumber; // // /** // * The first line of the customer's address. // */ // public String getAddressLine1() { // return addressLine1; // } // // /** // * The second line of the customer's address. // */ // public String getAddressLine2() { // return addressLine2; // } // // /** // * The third line of the customer's address. // */ // public String getAddressLine3() { // return addressLine3; // } // // /** // * The city of the customer's address. // */ // public String getCity() { // return city; // } // // /** // * Customer's company name. Required unless a `given_name` and `family_name` are provided. For // * Canadian customers, the use of a `company_name` value will mean that any mandate created from // * this customer will be considered to be a "Business PAD" (otherwise, any mandate will be // * considered to be a "Personal PAD"). // */ // public String getCompanyName() { // return companyName; // } // // /** // * [ISO 3166-1 alpha-2 // * code.](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements) // */ // public String getCountryCode() { // return countryCode; // } // // /** // * Fixed [timestamp](#api-usage-time-zones--dates), recording when this resource was created. // */ // public String getCreatedAt() { // return createdAt; // } // // /** // * For Danish customers only. The civic/company number (CPR or CVR) of the customer. Must be // * supplied if the customer's bank account is denominated in Danish krone (DKK). // */ // public String getDanishIdentityNumber() { // return danishIdentityNumber; // } // // /** // * Customer's email address. Required in most cases, as this allows GoCardless to send // * notifications to this customer. // */ // public String getEmail() { // return email; // } // // /** // * Customer's surname. Required unless a `company_name` is provided. // */ // public String getFamilyName() { // return familyName; // } // // /** // * Customer's first name. Required unless a `company_name` is provided. // */ // public String getGivenName() { // return givenName; // } // // /** // * Unique identifier, beginning with "CU". // */ // public String getId() { // return id; // } // // /** // * [ISO 639-1](http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) code. Used as the language // * for notification emails sent by GoCardless if your organisation does not send its own (see // * [compliance requirements](#appendix-compliance-requirements)). Currently only "en", "fr", // * "de", "pt", "es", "it", "nl", "da", "nb", "sl", "sv" are supported. If this is not provided, // * the language will be chosen based on the `country_code` (if supplied) or default to "en". // */ // public String getLanguage() { // return language; // } // // /** // * Key-value store of custom data. Up to 3 keys are permitted, with key names up to 50 // * characters and values up to 500 characters. // */ // public Map<String, String> getMetadata() { // return metadata; // } // // /** // * [ITU E.123](https://en.wikipedia.org/wiki/E.123) formatted phone number, including country // * code. // */ // public String getPhoneNumber() { // return phoneNumber; // } // // /** // * The customer's postal code. // */ // public String getPostalCode() { // return postalCode; // } // // /** // * The customer's address region, county or department. For US customers a 2 letter // * [ISO3166-2:US](https://en.wikipedia.org/wiki/ISO_3166-2:US) state code is required (e.g. `CA` // * for California). // */ // public String getRegion() { // return region; // } // // /** // * For Swedish customers only. The civic/company number (personnummer, samordningsnummer, or // * organisationsnummer) of the customer. Must be supplied if the customer's bank account is // * denominated in Swedish krona (SEK). This field cannot be changed once it has been set. // */ // public String getSwedishIdentityNumber() { // return swedishIdentityNumber; // } // }
import com.gocardless.http.*; import com.gocardless.resources.Customer; import com.google.common.collect.ImmutableMap; import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; import java.util.HashMap; import java.util.List; import java.util.Map;
package com.gocardless.services; /** * Service class for working with customer resources. * * Customer objects hold the contact details for a customer. A customer can have several [customer * bank accounts](#core-endpoints-customer-bank-accounts), which in turn can have several Direct * Debit [mandates](#core-endpoints-mandates). */ public class CustomerService { private final HttpClient httpClient; /** * Constructor. Users of this library should have no need to call this - an instance of this * class can be obtained by calling {@link com.gocardless.GoCardlessClient#customers() }. */ public CustomerService(HttpClient httpClient) { this.httpClient = httpClient; } /** * Creates a new customer object. */ public CustomerCreateRequest create() { return new CustomerCreateRequest(httpClient); } /** * Returns a [cursor-paginated](#api-usage-cursor-pagination) list of your customers. */
// Path: src/main/java/com/gocardless/resources/Customer.java // public class Customer { // private Customer() { // // blank to prevent instantiation // } // // private String addressLine1; // private String addressLine2; // private String addressLine3; // private String city; // private String companyName; // private String countryCode; // private String createdAt; // private String danishIdentityNumber; // private String email; // private String familyName; // private String givenName; // private String id; // private String language; // private Map<String, String> metadata; // private String phoneNumber; // private String postalCode; // private String region; // private String swedishIdentityNumber; // // /** // * The first line of the customer's address. // */ // public String getAddressLine1() { // return addressLine1; // } // // /** // * The second line of the customer's address. // */ // public String getAddressLine2() { // return addressLine2; // } // // /** // * The third line of the customer's address. // */ // public String getAddressLine3() { // return addressLine3; // } // // /** // * The city of the customer's address. // */ // public String getCity() { // return city; // } // // /** // * Customer's company name. Required unless a `given_name` and `family_name` are provided. For // * Canadian customers, the use of a `company_name` value will mean that any mandate created from // * this customer will be considered to be a "Business PAD" (otherwise, any mandate will be // * considered to be a "Personal PAD"). // */ // public String getCompanyName() { // return companyName; // } // // /** // * [ISO 3166-1 alpha-2 // * code.](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements) // */ // public String getCountryCode() { // return countryCode; // } // // /** // * Fixed [timestamp](#api-usage-time-zones--dates), recording when this resource was created. // */ // public String getCreatedAt() { // return createdAt; // } // // /** // * For Danish customers only. The civic/company number (CPR or CVR) of the customer. Must be // * supplied if the customer's bank account is denominated in Danish krone (DKK). // */ // public String getDanishIdentityNumber() { // return danishIdentityNumber; // } // // /** // * Customer's email address. Required in most cases, as this allows GoCardless to send // * notifications to this customer. // */ // public String getEmail() { // return email; // } // // /** // * Customer's surname. Required unless a `company_name` is provided. // */ // public String getFamilyName() { // return familyName; // } // // /** // * Customer's first name. Required unless a `company_name` is provided. // */ // public String getGivenName() { // return givenName; // } // // /** // * Unique identifier, beginning with "CU". // */ // public String getId() { // return id; // } // // /** // * [ISO 639-1](http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) code. Used as the language // * for notification emails sent by GoCardless if your organisation does not send its own (see // * [compliance requirements](#appendix-compliance-requirements)). Currently only "en", "fr", // * "de", "pt", "es", "it", "nl", "da", "nb", "sl", "sv" are supported. If this is not provided, // * the language will be chosen based on the `country_code` (if supplied) or default to "en". // */ // public String getLanguage() { // return language; // } // // /** // * Key-value store of custom data. Up to 3 keys are permitted, with key names up to 50 // * characters and values up to 500 characters. // */ // public Map<String, String> getMetadata() { // return metadata; // } // // /** // * [ITU E.123](https://en.wikipedia.org/wiki/E.123) formatted phone number, including country // * code. // */ // public String getPhoneNumber() { // return phoneNumber; // } // // /** // * The customer's postal code. // */ // public String getPostalCode() { // return postalCode; // } // // /** // * The customer's address region, county or department. For US customers a 2 letter // * [ISO3166-2:US](https://en.wikipedia.org/wiki/ISO_3166-2:US) state code is required (e.g. `CA` // * for California). // */ // public String getRegion() { // return region; // } // // /** // * For Swedish customers only. The civic/company number (personnummer, samordningsnummer, or // * organisationsnummer) of the customer. Must be supplied if the customer's bank account is // * denominated in Swedish krona (SEK). This field cannot be changed once it has been set. // */ // public String getSwedishIdentityNumber() { // return swedishIdentityNumber; // } // } // Path: src/main/java/com/gocardless/services/CustomerService.java import com.gocardless.http.*; import com.gocardless.resources.Customer; import com.google.common.collect.ImmutableMap; import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; import java.util.HashMap; import java.util.List; import java.util.Map; package com.gocardless.services; /** * Service class for working with customer resources. * * Customer objects hold the contact details for a customer. A customer can have several [customer * bank accounts](#core-endpoints-customer-bank-accounts), which in turn can have several Direct * Debit [mandates](#core-endpoints-mandates). */ public class CustomerService { private final HttpClient httpClient; /** * Constructor. Users of this library should have no need to call this - an instance of this * class can be obtained by calling {@link com.gocardless.GoCardlessClient#customers() }. */ public CustomerService(HttpClient httpClient) { this.httpClient = httpClient; } /** * Creates a new customer object. */ public CustomerCreateRequest create() { return new CustomerCreateRequest(httpClient); } /** * Returns a [cursor-paginated](#api-usage-cursor-pagination) list of your customers. */
public CustomerListRequest<ListResponse<Customer>> list() {
gocardless/gocardless-pro-java
src/main/java/com/gocardless/services/MandateService.java
// Path: src/main/java/com/gocardless/resources/Mandate.java // public class Mandate { // private Mandate() { // // blank to prevent instantiation // } // // private String createdAt; // private String id; // private Links links; // private Map<String, String> metadata; // private String nextPossibleChargeDate; // private Boolean paymentsRequireApproval; // private String reference; // private String scheme; // private Status status; // // /** // * Fixed [timestamp](#api-usage-time-zones--dates), recording when this resource was created. // */ // public String getCreatedAt() { // return createdAt; // } // // /** // * Unique identifier, beginning with "MD". Note that this prefix may not apply to mandates // * created before 2016. // */ // public String getId() { // return id; // } // // public Links getLinks() { // return links; // } // // /** // * Key-value store of custom data. Up to 3 keys are permitted, with key names up to 50 // * characters and values up to 500 characters. // */ // public Map<String, String> getMetadata() { // return metadata; // } // // /** // * The earliest date that can be used as a `charge_date` on any newly created payment for this // * mandate. This value will change over time. // */ // public String getNextPossibleChargeDate() { // return nextPossibleChargeDate; // } // // /** // * Boolean value showing whether payments and subscriptions under this mandate require approval // * via an automated email before being processed. // */ // public Boolean getPaymentsRequireApproval() { // return paymentsRequireApproval; // } // // /** // * Unique reference. Different schemes have different length and [character // * set](#appendix-character-sets) requirements. GoCardless will generate a unique reference // * satisfying the different scheme requirements if this field is left blank. // */ // public String getReference() { // return reference; // } // // /** // * <a name="mandates_scheme"></a>Direct Debit scheme to which this mandate and associated // * payments are submitted. Can be supplied or automatically detected from the customer's bank // * account. // */ // public String getScheme() { // return scheme; // } // // /** // * One of: // * <ul> // * <li>`pending_customer_approval`: the mandate has not yet been signed by the second // * customer</li> // * <li>`pending_submission`: the mandate has not yet been submitted to the customer's bank</li> // * <li>`submitted`: the mandate has been submitted to the customer's bank but has not been // * processed yet</li> // * <li>`active`: the mandate has been successfully set up by the customer's bank</li> // * <li>`failed`: the mandate could not be created</li> // * <li>`cancelled`: the mandate has been cancelled</li> // * <li>`expired`: the mandate has expired due to dormancy</li> // * <li>`consumed`: the mandate has been consumed and cannot be reused (note that this only // * applies to schemes that are per-payment authorised)</li> // * <li>`blocked`: the mandate has been blocked and payments cannot be created</li> // * </ul> // */ // public Status getStatus() { // return status; // } // // public enum Status { // @SerializedName("pending_customer_approval") // PENDING_CUSTOMER_APPROVAL, @SerializedName("pending_submission") // PENDING_SUBMISSION, @SerializedName("submitted") // SUBMITTED, @SerializedName("active") // ACTIVE, @SerializedName("failed") // FAILED, @SerializedName("cancelled") // CANCELLED, @SerializedName("expired") // EXPIRED, @SerializedName("consumed") // CONSUMED, @SerializedName("blocked") // BLOCKED, @SerializedName("unknown") // UNKNOWN // } // // public static class Links { // private Links() { // // blank to prevent instantiation // } // // private String creditor; // private String customer; // private String customerBankAccount; // private String newMandate; // // /** // * ID of the associated [creditor](#core-endpoints-creditors). // */ // public String getCreditor() { // return creditor; // } // // /** // * ID of the associated [customer](#core-endpoints-customers) // */ // public String getCustomer() { // return customer; // } // // /** // * ID of the associated [customer bank account](#core-endpoints-customer-bank-accounts) // * which the mandate is created and submits payments against. // */ // public String getCustomerBankAccount() { // return customerBankAccount; // } // // /** // * ID of the new mandate if this mandate has been replaced. // */ // public String getNewMandate() { // return newMandate; // } // } // }
import com.gocardless.http.*; import com.gocardless.resources.Mandate; import com.google.common.base.Joiner; import com.google.common.collect.ImmutableMap; import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;
package com.gocardless.services; /** * Service class for working with mandate resources. * * Mandates represent the Direct Debit mandate with a [customer](#core-endpoints-customers). * * GoCardless will notify you via a [webhook](#appendix-webhooks) whenever the status of a mandate * changes. */ public class MandateService { private final HttpClient httpClient; /** * Constructor. Users of this library should have no need to call this - an instance of this * class can be obtained by calling {@link com.gocardless.GoCardlessClient#mandates() }. */ public MandateService(HttpClient httpClient) { this.httpClient = httpClient; } /** * Creates a new mandate object. */ public MandateCreateRequest create() { return new MandateCreateRequest(httpClient); } /** * Returns a [cursor-paginated](#api-usage-cursor-pagination) list of your mandates. */
// Path: src/main/java/com/gocardless/resources/Mandate.java // public class Mandate { // private Mandate() { // // blank to prevent instantiation // } // // private String createdAt; // private String id; // private Links links; // private Map<String, String> metadata; // private String nextPossibleChargeDate; // private Boolean paymentsRequireApproval; // private String reference; // private String scheme; // private Status status; // // /** // * Fixed [timestamp](#api-usage-time-zones--dates), recording when this resource was created. // */ // public String getCreatedAt() { // return createdAt; // } // // /** // * Unique identifier, beginning with "MD". Note that this prefix may not apply to mandates // * created before 2016. // */ // public String getId() { // return id; // } // // public Links getLinks() { // return links; // } // // /** // * Key-value store of custom data. Up to 3 keys are permitted, with key names up to 50 // * characters and values up to 500 characters. // */ // public Map<String, String> getMetadata() { // return metadata; // } // // /** // * The earliest date that can be used as a `charge_date` on any newly created payment for this // * mandate. This value will change over time. // */ // public String getNextPossibleChargeDate() { // return nextPossibleChargeDate; // } // // /** // * Boolean value showing whether payments and subscriptions under this mandate require approval // * via an automated email before being processed. // */ // public Boolean getPaymentsRequireApproval() { // return paymentsRequireApproval; // } // // /** // * Unique reference. Different schemes have different length and [character // * set](#appendix-character-sets) requirements. GoCardless will generate a unique reference // * satisfying the different scheme requirements if this field is left blank. // */ // public String getReference() { // return reference; // } // // /** // * <a name="mandates_scheme"></a>Direct Debit scheme to which this mandate and associated // * payments are submitted. Can be supplied or automatically detected from the customer's bank // * account. // */ // public String getScheme() { // return scheme; // } // // /** // * One of: // * <ul> // * <li>`pending_customer_approval`: the mandate has not yet been signed by the second // * customer</li> // * <li>`pending_submission`: the mandate has not yet been submitted to the customer's bank</li> // * <li>`submitted`: the mandate has been submitted to the customer's bank but has not been // * processed yet</li> // * <li>`active`: the mandate has been successfully set up by the customer's bank</li> // * <li>`failed`: the mandate could not be created</li> // * <li>`cancelled`: the mandate has been cancelled</li> // * <li>`expired`: the mandate has expired due to dormancy</li> // * <li>`consumed`: the mandate has been consumed and cannot be reused (note that this only // * applies to schemes that are per-payment authorised)</li> // * <li>`blocked`: the mandate has been blocked and payments cannot be created</li> // * </ul> // */ // public Status getStatus() { // return status; // } // // public enum Status { // @SerializedName("pending_customer_approval") // PENDING_CUSTOMER_APPROVAL, @SerializedName("pending_submission") // PENDING_SUBMISSION, @SerializedName("submitted") // SUBMITTED, @SerializedName("active") // ACTIVE, @SerializedName("failed") // FAILED, @SerializedName("cancelled") // CANCELLED, @SerializedName("expired") // EXPIRED, @SerializedName("consumed") // CONSUMED, @SerializedName("blocked") // BLOCKED, @SerializedName("unknown") // UNKNOWN // } // // public static class Links { // private Links() { // // blank to prevent instantiation // } // // private String creditor; // private String customer; // private String customerBankAccount; // private String newMandate; // // /** // * ID of the associated [creditor](#core-endpoints-creditors). // */ // public String getCreditor() { // return creditor; // } // // /** // * ID of the associated [customer](#core-endpoints-customers) // */ // public String getCustomer() { // return customer; // } // // /** // * ID of the associated [customer bank account](#core-endpoints-customer-bank-accounts) // * which the mandate is created and submits payments against. // */ // public String getCustomerBankAccount() { // return customerBankAccount; // } // // /** // * ID of the new mandate if this mandate has been replaced. // */ // public String getNewMandate() { // return newMandate; // } // } // } // Path: src/main/java/com/gocardless/services/MandateService.java import com.gocardless.http.*; import com.gocardless.resources.Mandate; import com.google.common.base.Joiner; import com.google.common.collect.ImmutableMap; import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; package com.gocardless.services; /** * Service class for working with mandate resources. * * Mandates represent the Direct Debit mandate with a [customer](#core-endpoints-customers). * * GoCardless will notify you via a [webhook](#appendix-webhooks) whenever the status of a mandate * changes. */ public class MandateService { private final HttpClient httpClient; /** * Constructor. Users of this library should have no need to call this - an instance of this * class can be obtained by calling {@link com.gocardless.GoCardlessClient#mandates() }. */ public MandateService(HttpClient httpClient) { this.httpClient = httpClient; } /** * Creates a new mandate object. */ public MandateCreateRequest create() { return new MandateCreateRequest(httpClient); } /** * Returns a [cursor-paginated](#api-usage-cursor-pagination) list of your mandates. */
public MandateListRequest<ListResponse<Mandate>> list() {
gocardless/gocardless-pro-java
src/test/java/com/gocardless/http/DeleteRequestTest.java
// Path: src/test/java/com/gocardless/http/HttpTestUtil.java // public static class DummyItem { // public String stringField; // public int intField; // }
import static org.assertj.core.api.Assertions.assertThat; import com.gocardless.http.HttpTestUtil.DummyItem; import com.google.common.collect.ImmutableMap; import org.junit.Rule; import org.junit.Test;
package com.gocardless.http; public class DeleteRequestTest { @Rule public final MockHttp http = new MockHttp(); @Test public void shouldPerformDeleteRequest() throws Exception { http.enqueueResponse(200, "fixtures/single.json");
// Path: src/test/java/com/gocardless/http/HttpTestUtil.java // public static class DummyItem { // public String stringField; // public int intField; // } // Path: src/test/java/com/gocardless/http/DeleteRequestTest.java import static org.assertj.core.api.Assertions.assertThat; import com.gocardless.http.HttpTestUtil.DummyItem; import com.google.common.collect.ImmutableMap; import org.junit.Rule; import org.junit.Test; package com.gocardless.http; public class DeleteRequestTest { @Rule public final MockHttp http = new MockHttp(); @Test public void shouldPerformDeleteRequest() throws Exception { http.enqueueResponse(200, "fixtures/single.json");
DummyItem result = new DummyDeleteRequest().execute();
gocardless/gocardless-pro-java
src/main/java/com/gocardless/services/MandateImportEntryService.java
// Path: src/main/java/com/gocardless/resources/MandateImportEntry.java // public class MandateImportEntry { // private MandateImportEntry() { // // blank to prevent instantiation // } // // private String createdAt; // private Links links; // private String recordIdentifier; // // /** // * Fixed [timestamp](#api-usage-time-zones--dates), recording when this resource was created. // */ // public String getCreatedAt() { // return createdAt; // } // // /** // * Related resources // */ // public Links getLinks() { // return links; // } // // /** // * A unique identifier for this entry, which you can use (once the import has been processed by // * GoCardless) to identify the records that have been created. Limited to 255 characters. // * // */ // public String getRecordIdentifier() { // return recordIdentifier; // } // // /** // * Represents a link resource returned from the API. // * // * Related resources // */ // public static class Links { // private Links() { // // blank to prevent instantiation // } // // private String customer; // private String customerBankAccount; // private String mandate; // private String mandateImport; // // /** // * The ID of the customer which was created when the mandate import was processed. // */ // public String getCustomer() { // return customer; // } // // /** // * The ID of the customer bank account which was created when the mandate import was // * processed. // */ // public String getCustomerBankAccount() { // return customerBankAccount; // } // // /** // * The ID of the mandate which was created when the mandate import was processed. // */ // public String getMandate() { // return mandate; // } // // /** // * The ID of the mandate import. This is returned when you [create a Mandate // * Import](#mandate-imports-create-a-new-mandate-import). // * // */ // public String getMandateImport() { // return mandateImport; // } // } // }
import com.gocardless.http.*; import com.gocardless.resources.MandateImportEntry; import com.google.common.collect.ImmutableMap; import com.google.gson.reflect.TypeToken; import java.util.List; import java.util.Map;
package com.gocardless.services; /** * Service class for working with mandate import entry resources. * * Mandate Import Entries are added to a [Mandate Import](#core-endpoints-mandate-imports). Each * entry corresponds to one mandate to be imported into GoCardless. * * To import a mandate you will need: * <ol> * <li>Identifying information about the customer (name/company and address)</li> * <li>Bank account details, consisting of an account holder name and either an IBAN or * <a href="#appendix-local-bank-details">local bank details</a></li> * <li>Amendment details (SEPA only)</li> * </ol> * * We suggest you provide a `record_identifier` (which is unique within the context of a single * mandate import) to help you to identify mandates that have been created once the import has been * processed by GoCardless. You can [list the mandate import * entries](#mandate-import-entries-list-all-mandate-import-entries), match them up in your system * using the `record_identifier`, and look at the `links` fields to find the mandate, customer and * customer bank account that have been imported. * * <p class="restricted-notice"> * <strong>Restricted</strong>: This API is currently only available for approved integrators - * please <a href="mailto:help@gocardless.com">get in touch</a> if you would like to use this API. * </p> */ public class MandateImportEntryService { private final HttpClient httpClient; /** * Constructor. Users of this library should have no need to call this - an instance of this * class can be obtained by calling * {@link com.gocardless.GoCardlessClient#mandateImportEntries() }. */ public MandateImportEntryService(HttpClient httpClient) { this.httpClient = httpClient; } /** * For an existing [mandate import](#core-endpoints-mandate-imports), this endpoint can be used * to add individual mandates to be imported into GoCardless. * * You can add no more than 30,000 rows to a single mandate import. If you attempt to go over * this limit, the API will return a `record_limit_exceeded` error. */ public MandateImportEntryCreateRequest create() { return new MandateImportEntryCreateRequest(httpClient); } /** * For an existing mandate import, this endpoint lists all of the entries attached. * * After a mandate import has been submitted, you can use this endpoint to associate records in * your system (using the `record_identifier` that you provided when creating the mandate * import). * */
// Path: src/main/java/com/gocardless/resources/MandateImportEntry.java // public class MandateImportEntry { // private MandateImportEntry() { // // blank to prevent instantiation // } // // private String createdAt; // private Links links; // private String recordIdentifier; // // /** // * Fixed [timestamp](#api-usage-time-zones--dates), recording when this resource was created. // */ // public String getCreatedAt() { // return createdAt; // } // // /** // * Related resources // */ // public Links getLinks() { // return links; // } // // /** // * A unique identifier for this entry, which you can use (once the import has been processed by // * GoCardless) to identify the records that have been created. Limited to 255 characters. // * // */ // public String getRecordIdentifier() { // return recordIdentifier; // } // // /** // * Represents a link resource returned from the API. // * // * Related resources // */ // public static class Links { // private Links() { // // blank to prevent instantiation // } // // private String customer; // private String customerBankAccount; // private String mandate; // private String mandateImport; // // /** // * The ID of the customer which was created when the mandate import was processed. // */ // public String getCustomer() { // return customer; // } // // /** // * The ID of the customer bank account which was created when the mandate import was // * processed. // */ // public String getCustomerBankAccount() { // return customerBankAccount; // } // // /** // * The ID of the mandate which was created when the mandate import was processed. // */ // public String getMandate() { // return mandate; // } // // /** // * The ID of the mandate import. This is returned when you [create a Mandate // * Import](#mandate-imports-create-a-new-mandate-import). // * // */ // public String getMandateImport() { // return mandateImport; // } // } // } // Path: src/main/java/com/gocardless/services/MandateImportEntryService.java import com.gocardless.http.*; import com.gocardless.resources.MandateImportEntry; import com.google.common.collect.ImmutableMap; import com.google.gson.reflect.TypeToken; import java.util.List; import java.util.Map; package com.gocardless.services; /** * Service class for working with mandate import entry resources. * * Mandate Import Entries are added to a [Mandate Import](#core-endpoints-mandate-imports). Each * entry corresponds to one mandate to be imported into GoCardless. * * To import a mandate you will need: * <ol> * <li>Identifying information about the customer (name/company and address)</li> * <li>Bank account details, consisting of an account holder name and either an IBAN or * <a href="#appendix-local-bank-details">local bank details</a></li> * <li>Amendment details (SEPA only)</li> * </ol> * * We suggest you provide a `record_identifier` (which is unique within the context of a single * mandate import) to help you to identify mandates that have been created once the import has been * processed by GoCardless. You can [list the mandate import * entries](#mandate-import-entries-list-all-mandate-import-entries), match them up in your system * using the `record_identifier`, and look at the `links` fields to find the mandate, customer and * customer bank account that have been imported. * * <p class="restricted-notice"> * <strong>Restricted</strong>: This API is currently only available for approved integrators - * please <a href="mailto:help@gocardless.com">get in touch</a> if you would like to use this API. * </p> */ public class MandateImportEntryService { private final HttpClient httpClient; /** * Constructor. Users of this library should have no need to call this - an instance of this * class can be obtained by calling * {@link com.gocardless.GoCardlessClient#mandateImportEntries() }. */ public MandateImportEntryService(HttpClient httpClient) { this.httpClient = httpClient; } /** * For an existing [mandate import](#core-endpoints-mandate-imports), this endpoint can be used * to add individual mandates to be imported into GoCardless. * * You can add no more than 30,000 rows to a single mandate import. If you attempt to go over * this limit, the API will return a `record_limit_exceeded` error. */ public MandateImportEntryCreateRequest create() { return new MandateImportEntryCreateRequest(httpClient); } /** * For an existing mandate import, this endpoint lists all of the entries attached. * * After a mandate import has been submitted, you can use this endpoint to associate records in * your system (using the `record_identifier` that you provided when creating the mandate * import). * */
public MandateImportEntryListRequest<ListResponse<MandateImportEntry>> list() {
gocardless/gocardless-pro-java
src/test/java/com/gocardless/http/ListRequestTest.java
// Path: src/test/java/com/gocardless/http/HttpTestUtil.java // public static class DummyItem { // public String stringField; // public int intField; // }
import static org.assertj.core.api.Assertions.assertThat; import com.gocardless.http.HttpTestUtil.DummyItem; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.gson.reflect.TypeToken; import java.util.List; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException;
package com.gocardless.http; public class ListRequestTest { @Rule public final MockHttp http = new MockHttp(); @Rule public final ExpectedException exception = ExpectedException.none(); @Test public void shouldPerformListRequest() throws Exception { http.enqueueResponse(200, "fixtures/page.json");
// Path: src/test/java/com/gocardless/http/HttpTestUtil.java // public static class DummyItem { // public String stringField; // public int intField; // } // Path: src/test/java/com/gocardless/http/ListRequestTest.java import static org.assertj.core.api.Assertions.assertThat; import com.gocardless.http.HttpTestUtil.DummyItem; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.gson.reflect.TypeToken; import java.util.List; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; package com.gocardless.http; public class ListRequestTest { @Rule public final MockHttp http = new MockHttp(); @Rule public final ExpectedException exception = ExpectedException.none(); @Test public void shouldPerformListRequest() throws Exception { http.enqueueResponse(200, "fixtures/page.json");
ListResponse<DummyItem> result = DummyListRequest.pageRequest(http.client()).execute();
gocardless/gocardless-pro-java
src/main/java/com/gocardless/services/TaxRateService.java
// Path: src/main/java/com/gocardless/resources/TaxRate.java // public class TaxRate { // private TaxRate() { // // blank to prevent instantiation // } // // private String endDate; // private String id; // private String jurisdiction; // private String percentage; // private String startDate; // private String type; // // /** // * Date at which GoCardless stopped applying the tax rate for the jurisdiction. // */ // public String getEndDate() { // return endDate; // } // // /** // * The unique identifier created by the jurisdiction, tax type and version // */ // public String getId() { // return id; // } // // /** // * The jurisdiction this tax rate applies to // */ // public String getJurisdiction() { // return jurisdiction; // } // // /** // * The percentage of tax that is applied onto of GoCardless fees // */ // public String getPercentage() { // return percentage; // } // // /** // * Date at which GoCardless started applying the tax rate in the jurisdiction. // */ // public String getStartDate() { // return startDate; // } // // /** // * The type of tax applied by this rate // */ // public String getType() { // return type; // } // }
import com.gocardless.http.*; import com.gocardless.resources.TaxRate; import com.google.common.collect.ImmutableMap; import com.google.gson.reflect.TypeToken; import java.util.List; import java.util.Map;
package com.gocardless.services; /** * Service class for working with tax rate resources. * * Tax rates from tax authority. * * We also maintain a [static list of the tax rates for each jurisdiction](#appendix-tax-rates). */ public class TaxRateService { private final HttpClient httpClient; /** * Constructor. Users of this library should have no need to call this - an instance of this * class can be obtained by calling {@link com.gocardless.GoCardlessClient#taxRates() }. */ public TaxRateService(HttpClient httpClient) { this.httpClient = httpClient; } /** * Returns a [cursor-paginated](#api-usage-cursor-pagination) list of all tax rates. */
// Path: src/main/java/com/gocardless/resources/TaxRate.java // public class TaxRate { // private TaxRate() { // // blank to prevent instantiation // } // // private String endDate; // private String id; // private String jurisdiction; // private String percentage; // private String startDate; // private String type; // // /** // * Date at which GoCardless stopped applying the tax rate for the jurisdiction. // */ // public String getEndDate() { // return endDate; // } // // /** // * The unique identifier created by the jurisdiction, tax type and version // */ // public String getId() { // return id; // } // // /** // * The jurisdiction this tax rate applies to // */ // public String getJurisdiction() { // return jurisdiction; // } // // /** // * The percentage of tax that is applied onto of GoCardless fees // */ // public String getPercentage() { // return percentage; // } // // /** // * Date at which GoCardless started applying the tax rate in the jurisdiction. // */ // public String getStartDate() { // return startDate; // } // // /** // * The type of tax applied by this rate // */ // public String getType() { // return type; // } // } // Path: src/main/java/com/gocardless/services/TaxRateService.java import com.gocardless.http.*; import com.gocardless.resources.TaxRate; import com.google.common.collect.ImmutableMap; import com.google.gson.reflect.TypeToken; import java.util.List; import java.util.Map; package com.gocardless.services; /** * Service class for working with tax rate resources. * * Tax rates from tax authority. * * We also maintain a [static list of the tax rates for each jurisdiction](#appendix-tax-rates). */ public class TaxRateService { private final HttpClient httpClient; /** * Constructor. Users of this library should have no need to call this - an instance of this * class can be obtained by calling {@link com.gocardless.GoCardlessClient#taxRates() }. */ public TaxRateService(HttpClient httpClient) { this.httpClient = httpClient; } /** * Returns a [cursor-paginated](#api-usage-cursor-pagination) list of all tax rates. */
public TaxRateListRequest<ListResponse<TaxRate>> list() {
gocardless/gocardless-pro-java
src/main/java/com/gocardless/services/WebhookService.java
// Path: src/main/java/com/gocardless/resources/Webhook.java // public class Webhook { // private Webhook() { // // blank to prevent instantiation // } // // private String createdAt; // private String id; // private Boolean isTest; // private String requestBody; // private Map<String, String> requestHeaders; // private String responseBody; // private Boolean responseBodyTruncated; // private Integer responseCode; // private Map<String, String> responseHeaders; // private Boolean responseHeadersContentTruncated; // private Boolean responseHeadersCountTruncated; // private Boolean successful; // private String url; // // /** // * Fixed [timestamp](#api-usage-time-zones--dates), recording when this resource was created. // */ // public String getCreatedAt() { // return createdAt; // } // // /** // * Unique identifier, beginning with "WB". // */ // public String getId() { // return id; // } // // /** // * Boolean value showing whether this was a demo webhook for testing // */ // public Boolean getIsTest() { // return isTest; // } // // /** // * The body of the request sent to the webhook URL // */ // public String getRequestBody() { // return requestBody; // } // // /** // * The request headers sent with the webhook // */ // public Map<String, String> getRequestHeaders() { // return requestHeaders; // } // // /** // * The body of the response from the webhook URL // */ // public String getResponseBody() { // return responseBody; // } // // /** // * Boolean value indicating the webhook response body was truncated // */ // public Boolean getResponseBodyTruncated() { // return responseBodyTruncated; // } // // /** // * The response code from the webhook request // */ // public Integer getResponseCode() { // return responseCode; // } // // /** // * The headers sent with the response from the webhook URL // */ // public Map<String, String> getResponseHeaders() { // return responseHeaders; // } // // /** // * Boolean indicating the content of response headers was truncated // */ // public Boolean getResponseHeadersContentTruncated() { // return responseHeadersContentTruncated; // } // // /** // * Boolean indicating the number of response headers was truncated // */ // public Boolean getResponseHeadersCountTruncated() { // return responseHeadersCountTruncated; // } // // /** // * Boolean indicating whether the request was successful or failed // */ // public Boolean getSuccessful() { // return successful; // } // // /** // * URL the webhook was POST-ed to // */ // public String getUrl() { // return url; // } // }
import com.gocardless.http.*; import com.gocardless.resources.Webhook; import com.google.common.collect.ImmutableMap; import com.google.gson.reflect.TypeToken; import java.util.List; import java.util.Map;
package com.gocardless.services; /** * Service class for working with webhook resources. * * Basic description of a webhook */ public class WebhookService { private final HttpClient httpClient; /** * Constructor. Users of this library should have no need to call this - an instance of this * class can be obtained by calling {@link com.gocardless.GoCardlessClient#webhooks() }. */ public WebhookService(HttpClient httpClient) { this.httpClient = httpClient; } /** * Returns a [cursor-paginated](#api-usage-cursor-pagination) list of your webhooks. */
// Path: src/main/java/com/gocardless/resources/Webhook.java // public class Webhook { // private Webhook() { // // blank to prevent instantiation // } // // private String createdAt; // private String id; // private Boolean isTest; // private String requestBody; // private Map<String, String> requestHeaders; // private String responseBody; // private Boolean responseBodyTruncated; // private Integer responseCode; // private Map<String, String> responseHeaders; // private Boolean responseHeadersContentTruncated; // private Boolean responseHeadersCountTruncated; // private Boolean successful; // private String url; // // /** // * Fixed [timestamp](#api-usage-time-zones--dates), recording when this resource was created. // */ // public String getCreatedAt() { // return createdAt; // } // // /** // * Unique identifier, beginning with "WB". // */ // public String getId() { // return id; // } // // /** // * Boolean value showing whether this was a demo webhook for testing // */ // public Boolean getIsTest() { // return isTest; // } // // /** // * The body of the request sent to the webhook URL // */ // public String getRequestBody() { // return requestBody; // } // // /** // * The request headers sent with the webhook // */ // public Map<String, String> getRequestHeaders() { // return requestHeaders; // } // // /** // * The body of the response from the webhook URL // */ // public String getResponseBody() { // return responseBody; // } // // /** // * Boolean value indicating the webhook response body was truncated // */ // public Boolean getResponseBodyTruncated() { // return responseBodyTruncated; // } // // /** // * The response code from the webhook request // */ // public Integer getResponseCode() { // return responseCode; // } // // /** // * The headers sent with the response from the webhook URL // */ // public Map<String, String> getResponseHeaders() { // return responseHeaders; // } // // /** // * Boolean indicating the content of response headers was truncated // */ // public Boolean getResponseHeadersContentTruncated() { // return responseHeadersContentTruncated; // } // // /** // * Boolean indicating the number of response headers was truncated // */ // public Boolean getResponseHeadersCountTruncated() { // return responseHeadersCountTruncated; // } // // /** // * Boolean indicating whether the request was successful or failed // */ // public Boolean getSuccessful() { // return successful; // } // // /** // * URL the webhook was POST-ed to // */ // public String getUrl() { // return url; // } // } // Path: src/main/java/com/gocardless/services/WebhookService.java import com.gocardless.http.*; import com.gocardless.resources.Webhook; import com.google.common.collect.ImmutableMap; import com.google.gson.reflect.TypeToken; import java.util.List; import java.util.Map; package com.gocardless.services; /** * Service class for working with webhook resources. * * Basic description of a webhook */ public class WebhookService { private final HttpClient httpClient; /** * Constructor. Users of this library should have no need to call this - an instance of this * class can be obtained by calling {@link com.gocardless.GoCardlessClient#webhooks() }. */ public WebhookService(HttpClient httpClient) { this.httpClient = httpClient; } /** * Returns a [cursor-paginated](#api-usage-cursor-pagination) list of your webhooks. */
public WebhookListRequest<ListResponse<Webhook>> list() {
gocardless/gocardless-pro-java
src/test/java/com/gocardless/http/PutRequestTest.java
// Path: src/test/java/com/gocardless/http/HttpTestUtil.java // public static class DummyItem { // public String stringField; // public int intField; // }
import static org.assertj.core.api.Assertions.assertThat; import com.gocardless.http.HttpTestUtil.DummyItem; import com.google.common.collect.ImmutableMap; import org.junit.Rule; import org.junit.Test;
package com.gocardless.http; public class PutRequestTest { @Rule public final MockHttp http = new MockHttp(); @Test public void shouldPerformPutRequest() throws Exception { http.enqueueResponse(200, "fixtures/single.json");
// Path: src/test/java/com/gocardless/http/HttpTestUtil.java // public static class DummyItem { // public String stringField; // public int intField; // } // Path: src/test/java/com/gocardless/http/PutRequestTest.java import static org.assertj.core.api.Assertions.assertThat; import com.gocardless.http.HttpTestUtil.DummyItem; import com.google.common.collect.ImmutableMap; import org.junit.Rule; import org.junit.Test; package com.gocardless.http; public class PutRequestTest { @Rule public final MockHttp http = new MockHttp(); @Test public void shouldPerformPutRequest() throws Exception { http.enqueueResponse(200, "fixtures/single.json");
DummyItem result = new DummyPutRequest().execute();
gocardless/gocardless-pro-java
src/main/java/com/gocardless/services/CustomerBankAccountService.java
// Path: src/main/java/com/gocardless/resources/CustomerBankAccount.java // public class CustomerBankAccount { // private CustomerBankAccount() { // // blank to prevent instantiation // } // // private String accountHolderName; // private String accountNumberEnding; // private AccountType accountType; // private String bankName; // private String countryCode; // private String createdAt; // private String currency; // private Boolean enabled; // private String id; // private Links links; // private Map<String, String> metadata; // // /** // * Name of the account holder, as known by the bank. Usually this is the same as the name stored // * with the linked [creditor](#core-endpoints-creditors). This field will be transliterated, // * upcased and truncated to 18 characters. This field is required unless the request includes a // * [customer bank account token](#javascript-flow-customer-bank-account-tokens). // */ // public String getAccountHolderName() { // return accountHolderName; // } // // /** // * The last few digits of the account number. Currently 4 digits for NZD bank accounts and 2 // * digits for other currencies. // */ // public String getAccountNumberEnding() { // return accountNumberEnding; // } // // /** // * Bank account type. Required for USD-denominated bank accounts. Must not be provided for bank // * accounts in other currencies. See [local details](#local-bank-details-united-states) for more // * information. // */ // public AccountType getAccountType() { // return accountType; // } // // /** // * Name of bank, taken from the bank details. // */ // public String getBankName() { // return bankName; // } // // /** // * [ISO 3166-1 alpha-2 // * code](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements). // * Defaults to the country code of the `iban` if supplied, otherwise is required. // */ // public String getCountryCode() { // return countryCode; // } // // /** // * Fixed [timestamp](#api-usage-time-zones--dates), recording when this resource was created. // */ // public String getCreatedAt() { // return createdAt; // } // // /** // * [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217#Active_codes) currency code. Currently // * "AUD", "CAD", "DKK", "EUR", "GBP", "NZD", "SEK" and "USD" are supported. // */ // public String getCurrency() { // return currency; // } // // /** // * Boolean value showing whether the bank account is enabled or disabled. // */ // public Boolean getEnabled() { // return enabled; // } // // /** // * Unique identifier, beginning with "BA". // */ // public String getId() { // return id; // } // // public Links getLinks() { // return links; // } // // /** // * Key-value store of custom data. Up to 3 keys are permitted, with key names up to 50 // * characters and values up to 500 characters. // */ // public Map<String, String> getMetadata() { // return metadata; // } // // public enum AccountType { // @SerializedName("savings") // SAVINGS, @SerializedName("checking") // CHECKING, @SerializedName("unknown") // UNKNOWN // } // // public static class Links { // private Links() { // // blank to prevent instantiation // } // // private String customer; // // /** // * ID of the [customer](#core-endpoints-customers) that owns this bank account. // */ // public String getCustomer() { // return customer; // } // } // }
import com.gocardless.http.*; import com.gocardless.resources.CustomerBankAccount; import com.google.common.collect.ImmutableMap; import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; import java.util.HashMap; import java.util.List; import java.util.Map;
package com.gocardless.services; /** * Service class for working with customer bank account resources. * * Customer Bank Accounts hold the bank details of a [customer](#core-endpoints-customers). They * always belong to a [customer](#core-endpoints-customers), and may be linked to several Direct * Debit [mandates](#core-endpoints-mandates). * * Note that customer bank accounts must be unique, and so you will encounter a * `bank_account_exists` error if you try to create a duplicate bank account. You may wish to handle * this by updating the existing record instead, the ID of which will be provided as * `links[customer_bank_account]` in the error response. */ public class CustomerBankAccountService { private final HttpClient httpClient; /** * Constructor. Users of this library should have no need to call this - an instance of this * class can be obtained by calling * {@link com.gocardless.GoCardlessClient#customerBankAccounts() }. */ public CustomerBankAccountService(HttpClient httpClient) { this.httpClient = httpClient; } /** * Creates a new customer bank account object. * * There are three different ways to supply bank account details: * * - [Local details](#appendix-local-bank-details) * * - IBAN * * - [Customer Bank Account Tokens](#javascript-flow-create-a-customer-bank-account-token) * * For more information on the different fields required in each country, see [local bank * details](#appendix-local-bank-details). */ public CustomerBankAccountCreateRequest create() { return new CustomerBankAccountCreateRequest(httpClient); } /** * Returns a [cursor-paginated](#api-usage-cursor-pagination) list of your bank accounts. */
// Path: src/main/java/com/gocardless/resources/CustomerBankAccount.java // public class CustomerBankAccount { // private CustomerBankAccount() { // // blank to prevent instantiation // } // // private String accountHolderName; // private String accountNumberEnding; // private AccountType accountType; // private String bankName; // private String countryCode; // private String createdAt; // private String currency; // private Boolean enabled; // private String id; // private Links links; // private Map<String, String> metadata; // // /** // * Name of the account holder, as known by the bank. Usually this is the same as the name stored // * with the linked [creditor](#core-endpoints-creditors). This field will be transliterated, // * upcased and truncated to 18 characters. This field is required unless the request includes a // * [customer bank account token](#javascript-flow-customer-bank-account-tokens). // */ // public String getAccountHolderName() { // return accountHolderName; // } // // /** // * The last few digits of the account number. Currently 4 digits for NZD bank accounts and 2 // * digits for other currencies. // */ // public String getAccountNumberEnding() { // return accountNumberEnding; // } // // /** // * Bank account type. Required for USD-denominated bank accounts. Must not be provided for bank // * accounts in other currencies. See [local details](#local-bank-details-united-states) for more // * information. // */ // public AccountType getAccountType() { // return accountType; // } // // /** // * Name of bank, taken from the bank details. // */ // public String getBankName() { // return bankName; // } // // /** // * [ISO 3166-1 alpha-2 // * code](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements). // * Defaults to the country code of the `iban` if supplied, otherwise is required. // */ // public String getCountryCode() { // return countryCode; // } // // /** // * Fixed [timestamp](#api-usage-time-zones--dates), recording when this resource was created. // */ // public String getCreatedAt() { // return createdAt; // } // // /** // * [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217#Active_codes) currency code. Currently // * "AUD", "CAD", "DKK", "EUR", "GBP", "NZD", "SEK" and "USD" are supported. // */ // public String getCurrency() { // return currency; // } // // /** // * Boolean value showing whether the bank account is enabled or disabled. // */ // public Boolean getEnabled() { // return enabled; // } // // /** // * Unique identifier, beginning with "BA". // */ // public String getId() { // return id; // } // // public Links getLinks() { // return links; // } // // /** // * Key-value store of custom data. Up to 3 keys are permitted, with key names up to 50 // * characters and values up to 500 characters. // */ // public Map<String, String> getMetadata() { // return metadata; // } // // public enum AccountType { // @SerializedName("savings") // SAVINGS, @SerializedName("checking") // CHECKING, @SerializedName("unknown") // UNKNOWN // } // // public static class Links { // private Links() { // // blank to prevent instantiation // } // // private String customer; // // /** // * ID of the [customer](#core-endpoints-customers) that owns this bank account. // */ // public String getCustomer() { // return customer; // } // } // } // Path: src/main/java/com/gocardless/services/CustomerBankAccountService.java import com.gocardless.http.*; import com.gocardless.resources.CustomerBankAccount; import com.google.common.collect.ImmutableMap; import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; import java.util.HashMap; import java.util.List; import java.util.Map; package com.gocardless.services; /** * Service class for working with customer bank account resources. * * Customer Bank Accounts hold the bank details of a [customer](#core-endpoints-customers). They * always belong to a [customer](#core-endpoints-customers), and may be linked to several Direct * Debit [mandates](#core-endpoints-mandates). * * Note that customer bank accounts must be unique, and so you will encounter a * `bank_account_exists` error if you try to create a duplicate bank account. You may wish to handle * this by updating the existing record instead, the ID of which will be provided as * `links[customer_bank_account]` in the error response. */ public class CustomerBankAccountService { private final HttpClient httpClient; /** * Constructor. Users of this library should have no need to call this - an instance of this * class can be obtained by calling * {@link com.gocardless.GoCardlessClient#customerBankAccounts() }. */ public CustomerBankAccountService(HttpClient httpClient) { this.httpClient = httpClient; } /** * Creates a new customer bank account object. * * There are three different ways to supply bank account details: * * - [Local details](#appendix-local-bank-details) * * - IBAN * * - [Customer Bank Account Tokens](#javascript-flow-create-a-customer-bank-account-token) * * For more information on the different fields required in each country, see [local bank * details](#appendix-local-bank-details). */ public CustomerBankAccountCreateRequest create() { return new CustomerBankAccountCreateRequest(httpClient); } /** * Returns a [cursor-paginated](#api-usage-cursor-pagination) list of your bank accounts. */
public CustomerBankAccountListRequest<ListResponse<CustomerBankAccount>> list() {
gocardless/gocardless-pro-java
src/test/java/com/gocardless/GCEnumTypeAdapterFactoryTest.java
// Path: src/main/java/com/gocardless/http/GCEnumTypeAdapterFactory.java // public class GCEnumTypeAdapterFactory implements TypeAdapterFactory { // private static final String UNKNOWN = "unknown"; // // @Override // public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) { // Class<T> rawType = (Class<T>) type.getRawType(); // if (!rawType.isEnum()) { // return null; // } // final Map<String, T> nameToConstant = new HashMap<String, T>(); // final Map<T, String> constantToName = new HashMap<T, String>(); // try { // for (T constant : rawType.getEnumConstants()) { // String name = ((Enum) constant).name(); // SerializedName annotation = // rawType.getField(name).getAnnotation(SerializedName.class); // if (annotation != null) { // name = annotation.value(); // for (String alternate : annotation.alternate()) { // nameToConstant.put(alternate, constant); // } // } else { // name = constant.toString(); // } // nameToConstant.put(name, constant); // constantToName.put(constant, name); // } // } catch (NoSuchFieldException e) { // throw new AssertionError(e); // } // return new TypeAdapter<T>() { // @Override // public void write(JsonWriter out, T value) throws IOException { // out.value(value == null ? null : constantToName.get(value)); // } // // @Override // public T read(JsonReader in) throws IOException { // // if server sends null, show it as null // if (in.peek() == JsonToken.NULL) { // in.nextNull(); // return null; // } // /* // * if server sends new string which is not in enum then give Unknown else the // * default value which is a valid/existing enum // */ // String input = in.nextString(); // if (!nameToConstant.containsKey(input)) { // return nameToConstant.get(UNKNOWN); // } else { // return nameToConstant.get(input); // } // } // }; // } // }
import static org.assertj.core.api.Assertions.assertThat; import com.gocardless.http.GCEnumTypeAdapterFactory; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.annotations.SerializedName; import org.junit.Before; import org.junit.Test;
package com.gocardless; public class GCEnumTypeAdapterFactoryTest { enum Scheme { @SerializedName("bacs") BACS, @SerializedName("becs") BECS, @SerializedName("mos") MY_OWN_SCHEME, @SerializedName("unknown") UNKNOWN, SCHEME_WITHOUT_ANNOTATION; @Override public String toString() { return name().toLowerCase(); } }
// Path: src/main/java/com/gocardless/http/GCEnumTypeAdapterFactory.java // public class GCEnumTypeAdapterFactory implements TypeAdapterFactory { // private static final String UNKNOWN = "unknown"; // // @Override // public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) { // Class<T> rawType = (Class<T>) type.getRawType(); // if (!rawType.isEnum()) { // return null; // } // final Map<String, T> nameToConstant = new HashMap<String, T>(); // final Map<T, String> constantToName = new HashMap<T, String>(); // try { // for (T constant : rawType.getEnumConstants()) { // String name = ((Enum) constant).name(); // SerializedName annotation = // rawType.getField(name).getAnnotation(SerializedName.class); // if (annotation != null) { // name = annotation.value(); // for (String alternate : annotation.alternate()) { // nameToConstant.put(alternate, constant); // } // } else { // name = constant.toString(); // } // nameToConstant.put(name, constant); // constantToName.put(constant, name); // } // } catch (NoSuchFieldException e) { // throw new AssertionError(e); // } // return new TypeAdapter<T>() { // @Override // public void write(JsonWriter out, T value) throws IOException { // out.value(value == null ? null : constantToName.get(value)); // } // // @Override // public T read(JsonReader in) throws IOException { // // if server sends null, show it as null // if (in.peek() == JsonToken.NULL) { // in.nextNull(); // return null; // } // /* // * if server sends new string which is not in enum then give Unknown else the // * default value which is a valid/existing enum // */ // String input = in.nextString(); // if (!nameToConstant.containsKey(input)) { // return nameToConstant.get(UNKNOWN); // } else { // return nameToConstant.get(input); // } // } // }; // } // } // Path: src/test/java/com/gocardless/GCEnumTypeAdapterFactoryTest.java import static org.assertj.core.api.Assertions.assertThat; import com.gocardless.http.GCEnumTypeAdapterFactory; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.annotations.SerializedName; import org.junit.Before; import org.junit.Test; package com.gocardless; public class GCEnumTypeAdapterFactoryTest { enum Scheme { @SerializedName("bacs") BACS, @SerializedName("becs") BECS, @SerializedName("mos") MY_OWN_SCHEME, @SerializedName("unknown") UNKNOWN, SCHEME_WITHOUT_ANNOTATION; @Override public String toString() { return name().toLowerCase(); } }
GCEnumTypeAdapterFactory gcEnumTypeAdapterFactory = new GCEnumTypeAdapterFactory();
gocardless/gocardless-pro-java
src/main/java/com/gocardless/http/ResponseParser.java
// Path: src/main/java/com/gocardless/errors/ApiErrorResponse.java // public class ApiErrorResponse { // private static final Joiner JOINER = Joiner.on(", "); // private final String message; // private final ErrorType type; // private final String documentationUrl; // private final String requestId; // private final int code; // private final List<ApiError> errors; // // private ApiErrorResponse(String message, ErrorType type, String documentationUrl, // String requestId, int code, List<ApiError> errors) { // this.message = message; // this.type = type; // this.documentationUrl = documentationUrl; // this.requestId = requestId; // this.code = code; // this.errors = errors; // } // // String getMessage() { // return message; // } // // ErrorType getType() { // return type; // } // // String getDocumentationUrl() { // return documentationUrl; // } // // String getRequestId() { // return requestId; // } // // int getCode() { // return code; // } // // List<ApiError> getErrors() { // if (errors == null) { // return ImmutableList.of(); // } // return ImmutableList.copyOf(errors); // } // // @Override // public String toString() { // if (errors == null || errors.isEmpty()) { // return message; // } else { // return JOINER.join(errors); // } // } // } // // Path: src/main/java/com/gocardless/errors/GoCardlessApiException.java // public class GoCardlessApiException extends GoCardlessException { // private final ApiErrorResponse error; // // GoCardlessApiException(ApiErrorResponse error) { // super(error.toString()); // this.error = error; // } // // /** // * Returns a human-readable description of the error. // */ // public String getErrorMessage() { // return error.getMessage(); // } // // /** // * Returns the type of the error. // */ // public ErrorType getType() { // return error.getType(); // } // // /** // * Returns the URL to the documentation describing the error. // */ // public String getDocumentationUrl() { // return error.getDocumentationUrl(); // } // // /** // * Returns the ID of the request. This can be used to help the support team find your error // * quickly. // */ // public String getRequestId() { // return error.getRequestId(); // } // // /** // * Returns the HTTP status code. // */ // public int getCode() { // return error.getCode(); // } // // /** // * Returns a list of errors. // */ // public List<ApiError> getErrors() { // return error.getErrors(); // } // // @Override // public String toString() { // return error.toString(); // } // } // // Path: src/main/java/com/gocardless/errors/GoCardlessErrorMapper.java // public class GoCardlessErrorMapper { // /** // * Maps an error response to an exception. // * // * @param error the error response to map // */ // public static GoCardlessApiException toException(ApiErrorResponse error) { // switch (error.getCode()) { // case 401: // return new AuthenticationException(error); // case 403: // return new PermissionException(error); // case 429: // return new RateLimitException(error); // } // switch (error.getType()) { // case GOCARDLESS: // return new GoCardlessInternalException(error); // case INVALID_API_USAGE: // return new InvalidApiUsageException(error); // case INVALID_STATE: // return new InvalidStateException(error); // case VALIDATION_FAILED: // return new ValidationFailedException(error); // } // throw new IllegalStateException("Unknown error type: " + error.getType()); // } // } // // Path: src/main/java/com/gocardless/errors/MalformedResponseException.java // public class MalformedResponseException extends GoCardlessException { // private final String responseBody; // // public MalformedResponseException(String responseBody) { // super("Malformed response received from server"); // this.responseBody = responseBody; // } // // public String getResponseBody() { // return responseBody; // } // }
import com.gocardless.errors.ApiErrorResponse; import com.gocardless.errors.GoCardlessApiException; import com.gocardless.errors.GoCardlessErrorMapper; import com.gocardless.errors.MalformedResponseException; import com.google.common.collect.ImmutableList; import com.google.gson.*; import com.google.gson.reflect.TypeToken; import java.util.List;
package com.gocardless.http; final class ResponseParser { private final Gson gson; ResponseParser(Gson gson) { this.gson = gson; } <T> T parseSingle(String responseBody, String envelope, Class<T> clazz) { JsonElement json; try { json = new JsonParser().parse(responseBody); } catch (JsonSyntaxException e) {
// Path: src/main/java/com/gocardless/errors/ApiErrorResponse.java // public class ApiErrorResponse { // private static final Joiner JOINER = Joiner.on(", "); // private final String message; // private final ErrorType type; // private final String documentationUrl; // private final String requestId; // private final int code; // private final List<ApiError> errors; // // private ApiErrorResponse(String message, ErrorType type, String documentationUrl, // String requestId, int code, List<ApiError> errors) { // this.message = message; // this.type = type; // this.documentationUrl = documentationUrl; // this.requestId = requestId; // this.code = code; // this.errors = errors; // } // // String getMessage() { // return message; // } // // ErrorType getType() { // return type; // } // // String getDocumentationUrl() { // return documentationUrl; // } // // String getRequestId() { // return requestId; // } // // int getCode() { // return code; // } // // List<ApiError> getErrors() { // if (errors == null) { // return ImmutableList.of(); // } // return ImmutableList.copyOf(errors); // } // // @Override // public String toString() { // if (errors == null || errors.isEmpty()) { // return message; // } else { // return JOINER.join(errors); // } // } // } // // Path: src/main/java/com/gocardless/errors/GoCardlessApiException.java // public class GoCardlessApiException extends GoCardlessException { // private final ApiErrorResponse error; // // GoCardlessApiException(ApiErrorResponse error) { // super(error.toString()); // this.error = error; // } // // /** // * Returns a human-readable description of the error. // */ // public String getErrorMessage() { // return error.getMessage(); // } // // /** // * Returns the type of the error. // */ // public ErrorType getType() { // return error.getType(); // } // // /** // * Returns the URL to the documentation describing the error. // */ // public String getDocumentationUrl() { // return error.getDocumentationUrl(); // } // // /** // * Returns the ID of the request. This can be used to help the support team find your error // * quickly. // */ // public String getRequestId() { // return error.getRequestId(); // } // // /** // * Returns the HTTP status code. // */ // public int getCode() { // return error.getCode(); // } // // /** // * Returns a list of errors. // */ // public List<ApiError> getErrors() { // return error.getErrors(); // } // // @Override // public String toString() { // return error.toString(); // } // } // // Path: src/main/java/com/gocardless/errors/GoCardlessErrorMapper.java // public class GoCardlessErrorMapper { // /** // * Maps an error response to an exception. // * // * @param error the error response to map // */ // public static GoCardlessApiException toException(ApiErrorResponse error) { // switch (error.getCode()) { // case 401: // return new AuthenticationException(error); // case 403: // return new PermissionException(error); // case 429: // return new RateLimitException(error); // } // switch (error.getType()) { // case GOCARDLESS: // return new GoCardlessInternalException(error); // case INVALID_API_USAGE: // return new InvalidApiUsageException(error); // case INVALID_STATE: // return new InvalidStateException(error); // case VALIDATION_FAILED: // return new ValidationFailedException(error); // } // throw new IllegalStateException("Unknown error type: " + error.getType()); // } // } // // Path: src/main/java/com/gocardless/errors/MalformedResponseException.java // public class MalformedResponseException extends GoCardlessException { // private final String responseBody; // // public MalformedResponseException(String responseBody) { // super("Malformed response received from server"); // this.responseBody = responseBody; // } // // public String getResponseBody() { // return responseBody; // } // } // Path: src/main/java/com/gocardless/http/ResponseParser.java import com.gocardless.errors.ApiErrorResponse; import com.gocardless.errors.GoCardlessApiException; import com.gocardless.errors.GoCardlessErrorMapper; import com.gocardless.errors.MalformedResponseException; import com.google.common.collect.ImmutableList; import com.google.gson.*; import com.google.gson.reflect.TypeToken; import java.util.List; package com.gocardless.http; final class ResponseParser { private final Gson gson; ResponseParser(Gson gson) { this.gson = gson; } <T> T parseSingle(String responseBody, String envelope, Class<T> clazz) { JsonElement json; try { json = new JsonParser().parse(responseBody); } catch (JsonSyntaxException e) {
throw new MalformedResponseException(responseBody);
gocardless/gocardless-pro-java
src/main/java/com/gocardless/http/ResponseParser.java
// Path: src/main/java/com/gocardless/errors/ApiErrorResponse.java // public class ApiErrorResponse { // private static final Joiner JOINER = Joiner.on(", "); // private final String message; // private final ErrorType type; // private final String documentationUrl; // private final String requestId; // private final int code; // private final List<ApiError> errors; // // private ApiErrorResponse(String message, ErrorType type, String documentationUrl, // String requestId, int code, List<ApiError> errors) { // this.message = message; // this.type = type; // this.documentationUrl = documentationUrl; // this.requestId = requestId; // this.code = code; // this.errors = errors; // } // // String getMessage() { // return message; // } // // ErrorType getType() { // return type; // } // // String getDocumentationUrl() { // return documentationUrl; // } // // String getRequestId() { // return requestId; // } // // int getCode() { // return code; // } // // List<ApiError> getErrors() { // if (errors == null) { // return ImmutableList.of(); // } // return ImmutableList.copyOf(errors); // } // // @Override // public String toString() { // if (errors == null || errors.isEmpty()) { // return message; // } else { // return JOINER.join(errors); // } // } // } // // Path: src/main/java/com/gocardless/errors/GoCardlessApiException.java // public class GoCardlessApiException extends GoCardlessException { // private final ApiErrorResponse error; // // GoCardlessApiException(ApiErrorResponse error) { // super(error.toString()); // this.error = error; // } // // /** // * Returns a human-readable description of the error. // */ // public String getErrorMessage() { // return error.getMessage(); // } // // /** // * Returns the type of the error. // */ // public ErrorType getType() { // return error.getType(); // } // // /** // * Returns the URL to the documentation describing the error. // */ // public String getDocumentationUrl() { // return error.getDocumentationUrl(); // } // // /** // * Returns the ID of the request. This can be used to help the support team find your error // * quickly. // */ // public String getRequestId() { // return error.getRequestId(); // } // // /** // * Returns the HTTP status code. // */ // public int getCode() { // return error.getCode(); // } // // /** // * Returns a list of errors. // */ // public List<ApiError> getErrors() { // return error.getErrors(); // } // // @Override // public String toString() { // return error.toString(); // } // } // // Path: src/main/java/com/gocardless/errors/GoCardlessErrorMapper.java // public class GoCardlessErrorMapper { // /** // * Maps an error response to an exception. // * // * @param error the error response to map // */ // public static GoCardlessApiException toException(ApiErrorResponse error) { // switch (error.getCode()) { // case 401: // return new AuthenticationException(error); // case 403: // return new PermissionException(error); // case 429: // return new RateLimitException(error); // } // switch (error.getType()) { // case GOCARDLESS: // return new GoCardlessInternalException(error); // case INVALID_API_USAGE: // return new InvalidApiUsageException(error); // case INVALID_STATE: // return new InvalidStateException(error); // case VALIDATION_FAILED: // return new ValidationFailedException(error); // } // throw new IllegalStateException("Unknown error type: " + error.getType()); // } // } // // Path: src/main/java/com/gocardless/errors/MalformedResponseException.java // public class MalformedResponseException extends GoCardlessException { // private final String responseBody; // // public MalformedResponseException(String responseBody) { // super("Malformed response received from server"); // this.responseBody = responseBody; // } // // public String getResponseBody() { // return responseBody; // } // }
import com.gocardless.errors.ApiErrorResponse; import com.gocardless.errors.GoCardlessApiException; import com.gocardless.errors.GoCardlessErrorMapper; import com.gocardless.errors.MalformedResponseException; import com.google.common.collect.ImmutableList; import com.google.gson.*; import com.google.gson.reflect.TypeToken; import java.util.List;
json = new JsonParser().parse(responseBody); } catch (JsonSyntaxException e) { throw new MalformedResponseException(responseBody); } JsonObject object = json.getAsJsonObject().getAsJsonObject(envelope); return gson.fromJson(object, clazz); } <T> ImmutableList<T> parseMultiple(String responseBody, String envelope, TypeToken<List<T>> clazz) { JsonObject json = new JsonParser().parse(responseBody).getAsJsonObject(); JsonArray array = json.getAsJsonArray(envelope); List<T> items = gson.fromJson(array, clazz.getType()); return ImmutableList.copyOf(items); } <T> ImmutableList<T> parseMultiple(JsonObject json, String envelope, TypeToken<List<T>> clazz) { JsonArray array = json.getAsJsonArray(envelope); List<T> items = gson.fromJson(array, clazz.getType()); return ImmutableList.copyOf(items); } <T> ListResponse<T> parsePage(String responseBody, String envelope, TypeToken<List<T>> clazz) { JsonObject json = new JsonParser().parse(responseBody).getAsJsonObject(); List<T> items = parseMultiple(json, envelope, clazz); JsonObject metaJson = json.getAsJsonObject("meta"); ListResponse.Meta meta = gson.fromJson(metaJson, ListResponse.Meta.class); return new ListResponse<>(ImmutableList.copyOf(items), meta); }
// Path: src/main/java/com/gocardless/errors/ApiErrorResponse.java // public class ApiErrorResponse { // private static final Joiner JOINER = Joiner.on(", "); // private final String message; // private final ErrorType type; // private final String documentationUrl; // private final String requestId; // private final int code; // private final List<ApiError> errors; // // private ApiErrorResponse(String message, ErrorType type, String documentationUrl, // String requestId, int code, List<ApiError> errors) { // this.message = message; // this.type = type; // this.documentationUrl = documentationUrl; // this.requestId = requestId; // this.code = code; // this.errors = errors; // } // // String getMessage() { // return message; // } // // ErrorType getType() { // return type; // } // // String getDocumentationUrl() { // return documentationUrl; // } // // String getRequestId() { // return requestId; // } // // int getCode() { // return code; // } // // List<ApiError> getErrors() { // if (errors == null) { // return ImmutableList.of(); // } // return ImmutableList.copyOf(errors); // } // // @Override // public String toString() { // if (errors == null || errors.isEmpty()) { // return message; // } else { // return JOINER.join(errors); // } // } // } // // Path: src/main/java/com/gocardless/errors/GoCardlessApiException.java // public class GoCardlessApiException extends GoCardlessException { // private final ApiErrorResponse error; // // GoCardlessApiException(ApiErrorResponse error) { // super(error.toString()); // this.error = error; // } // // /** // * Returns a human-readable description of the error. // */ // public String getErrorMessage() { // return error.getMessage(); // } // // /** // * Returns the type of the error. // */ // public ErrorType getType() { // return error.getType(); // } // // /** // * Returns the URL to the documentation describing the error. // */ // public String getDocumentationUrl() { // return error.getDocumentationUrl(); // } // // /** // * Returns the ID of the request. This can be used to help the support team find your error // * quickly. // */ // public String getRequestId() { // return error.getRequestId(); // } // // /** // * Returns the HTTP status code. // */ // public int getCode() { // return error.getCode(); // } // // /** // * Returns a list of errors. // */ // public List<ApiError> getErrors() { // return error.getErrors(); // } // // @Override // public String toString() { // return error.toString(); // } // } // // Path: src/main/java/com/gocardless/errors/GoCardlessErrorMapper.java // public class GoCardlessErrorMapper { // /** // * Maps an error response to an exception. // * // * @param error the error response to map // */ // public static GoCardlessApiException toException(ApiErrorResponse error) { // switch (error.getCode()) { // case 401: // return new AuthenticationException(error); // case 403: // return new PermissionException(error); // case 429: // return new RateLimitException(error); // } // switch (error.getType()) { // case GOCARDLESS: // return new GoCardlessInternalException(error); // case INVALID_API_USAGE: // return new InvalidApiUsageException(error); // case INVALID_STATE: // return new InvalidStateException(error); // case VALIDATION_FAILED: // return new ValidationFailedException(error); // } // throw new IllegalStateException("Unknown error type: " + error.getType()); // } // } // // Path: src/main/java/com/gocardless/errors/MalformedResponseException.java // public class MalformedResponseException extends GoCardlessException { // private final String responseBody; // // public MalformedResponseException(String responseBody) { // super("Malformed response received from server"); // this.responseBody = responseBody; // } // // public String getResponseBody() { // return responseBody; // } // } // Path: src/main/java/com/gocardless/http/ResponseParser.java import com.gocardless.errors.ApiErrorResponse; import com.gocardless.errors.GoCardlessApiException; import com.gocardless.errors.GoCardlessErrorMapper; import com.gocardless.errors.MalformedResponseException; import com.google.common.collect.ImmutableList; import com.google.gson.*; import com.google.gson.reflect.TypeToken; import java.util.List; json = new JsonParser().parse(responseBody); } catch (JsonSyntaxException e) { throw new MalformedResponseException(responseBody); } JsonObject object = json.getAsJsonObject().getAsJsonObject(envelope); return gson.fromJson(object, clazz); } <T> ImmutableList<T> parseMultiple(String responseBody, String envelope, TypeToken<List<T>> clazz) { JsonObject json = new JsonParser().parse(responseBody).getAsJsonObject(); JsonArray array = json.getAsJsonArray(envelope); List<T> items = gson.fromJson(array, clazz.getType()); return ImmutableList.copyOf(items); } <T> ImmutableList<T> parseMultiple(JsonObject json, String envelope, TypeToken<List<T>> clazz) { JsonArray array = json.getAsJsonArray(envelope); List<T> items = gson.fromJson(array, clazz.getType()); return ImmutableList.copyOf(items); } <T> ListResponse<T> parsePage(String responseBody, String envelope, TypeToken<List<T>> clazz) { JsonObject json = new JsonParser().parse(responseBody).getAsJsonObject(); List<T> items = parseMultiple(json, envelope, clazz); JsonObject metaJson = json.getAsJsonObject("meta"); ListResponse.Meta meta = gson.fromJson(metaJson, ListResponse.Meta.class); return new ListResponse<>(ImmutableList.copyOf(items), meta); }
GoCardlessApiException parseError(String responseBody) {
gocardless/gocardless-pro-java
src/main/java/com/gocardless/http/ResponseParser.java
// Path: src/main/java/com/gocardless/errors/ApiErrorResponse.java // public class ApiErrorResponse { // private static final Joiner JOINER = Joiner.on(", "); // private final String message; // private final ErrorType type; // private final String documentationUrl; // private final String requestId; // private final int code; // private final List<ApiError> errors; // // private ApiErrorResponse(String message, ErrorType type, String documentationUrl, // String requestId, int code, List<ApiError> errors) { // this.message = message; // this.type = type; // this.documentationUrl = documentationUrl; // this.requestId = requestId; // this.code = code; // this.errors = errors; // } // // String getMessage() { // return message; // } // // ErrorType getType() { // return type; // } // // String getDocumentationUrl() { // return documentationUrl; // } // // String getRequestId() { // return requestId; // } // // int getCode() { // return code; // } // // List<ApiError> getErrors() { // if (errors == null) { // return ImmutableList.of(); // } // return ImmutableList.copyOf(errors); // } // // @Override // public String toString() { // if (errors == null || errors.isEmpty()) { // return message; // } else { // return JOINER.join(errors); // } // } // } // // Path: src/main/java/com/gocardless/errors/GoCardlessApiException.java // public class GoCardlessApiException extends GoCardlessException { // private final ApiErrorResponse error; // // GoCardlessApiException(ApiErrorResponse error) { // super(error.toString()); // this.error = error; // } // // /** // * Returns a human-readable description of the error. // */ // public String getErrorMessage() { // return error.getMessage(); // } // // /** // * Returns the type of the error. // */ // public ErrorType getType() { // return error.getType(); // } // // /** // * Returns the URL to the documentation describing the error. // */ // public String getDocumentationUrl() { // return error.getDocumentationUrl(); // } // // /** // * Returns the ID of the request. This can be used to help the support team find your error // * quickly. // */ // public String getRequestId() { // return error.getRequestId(); // } // // /** // * Returns the HTTP status code. // */ // public int getCode() { // return error.getCode(); // } // // /** // * Returns a list of errors. // */ // public List<ApiError> getErrors() { // return error.getErrors(); // } // // @Override // public String toString() { // return error.toString(); // } // } // // Path: src/main/java/com/gocardless/errors/GoCardlessErrorMapper.java // public class GoCardlessErrorMapper { // /** // * Maps an error response to an exception. // * // * @param error the error response to map // */ // public static GoCardlessApiException toException(ApiErrorResponse error) { // switch (error.getCode()) { // case 401: // return new AuthenticationException(error); // case 403: // return new PermissionException(error); // case 429: // return new RateLimitException(error); // } // switch (error.getType()) { // case GOCARDLESS: // return new GoCardlessInternalException(error); // case INVALID_API_USAGE: // return new InvalidApiUsageException(error); // case INVALID_STATE: // return new InvalidStateException(error); // case VALIDATION_FAILED: // return new ValidationFailedException(error); // } // throw new IllegalStateException("Unknown error type: " + error.getType()); // } // } // // Path: src/main/java/com/gocardless/errors/MalformedResponseException.java // public class MalformedResponseException extends GoCardlessException { // private final String responseBody; // // public MalformedResponseException(String responseBody) { // super("Malformed response received from server"); // this.responseBody = responseBody; // } // // public String getResponseBody() { // return responseBody; // } // }
import com.gocardless.errors.ApiErrorResponse; import com.gocardless.errors.GoCardlessApiException; import com.gocardless.errors.GoCardlessErrorMapper; import com.gocardless.errors.MalformedResponseException; import com.google.common.collect.ImmutableList; import com.google.gson.*; import com.google.gson.reflect.TypeToken; import java.util.List;
} catch (JsonSyntaxException e) { throw new MalformedResponseException(responseBody); } JsonObject object = json.getAsJsonObject().getAsJsonObject(envelope); return gson.fromJson(object, clazz); } <T> ImmutableList<T> parseMultiple(String responseBody, String envelope, TypeToken<List<T>> clazz) { JsonObject json = new JsonParser().parse(responseBody).getAsJsonObject(); JsonArray array = json.getAsJsonArray(envelope); List<T> items = gson.fromJson(array, clazz.getType()); return ImmutableList.copyOf(items); } <T> ImmutableList<T> parseMultiple(JsonObject json, String envelope, TypeToken<List<T>> clazz) { JsonArray array = json.getAsJsonArray(envelope); List<T> items = gson.fromJson(array, clazz.getType()); return ImmutableList.copyOf(items); } <T> ListResponse<T> parsePage(String responseBody, String envelope, TypeToken<List<T>> clazz) { JsonObject json = new JsonParser().parse(responseBody).getAsJsonObject(); List<T> items = parseMultiple(json, envelope, clazz); JsonObject metaJson = json.getAsJsonObject("meta"); ListResponse.Meta meta = gson.fromJson(metaJson, ListResponse.Meta.class); return new ListResponse<>(ImmutableList.copyOf(items), meta); } GoCardlessApiException parseError(String responseBody) {
// Path: src/main/java/com/gocardless/errors/ApiErrorResponse.java // public class ApiErrorResponse { // private static final Joiner JOINER = Joiner.on(", "); // private final String message; // private final ErrorType type; // private final String documentationUrl; // private final String requestId; // private final int code; // private final List<ApiError> errors; // // private ApiErrorResponse(String message, ErrorType type, String documentationUrl, // String requestId, int code, List<ApiError> errors) { // this.message = message; // this.type = type; // this.documentationUrl = documentationUrl; // this.requestId = requestId; // this.code = code; // this.errors = errors; // } // // String getMessage() { // return message; // } // // ErrorType getType() { // return type; // } // // String getDocumentationUrl() { // return documentationUrl; // } // // String getRequestId() { // return requestId; // } // // int getCode() { // return code; // } // // List<ApiError> getErrors() { // if (errors == null) { // return ImmutableList.of(); // } // return ImmutableList.copyOf(errors); // } // // @Override // public String toString() { // if (errors == null || errors.isEmpty()) { // return message; // } else { // return JOINER.join(errors); // } // } // } // // Path: src/main/java/com/gocardless/errors/GoCardlessApiException.java // public class GoCardlessApiException extends GoCardlessException { // private final ApiErrorResponse error; // // GoCardlessApiException(ApiErrorResponse error) { // super(error.toString()); // this.error = error; // } // // /** // * Returns a human-readable description of the error. // */ // public String getErrorMessage() { // return error.getMessage(); // } // // /** // * Returns the type of the error. // */ // public ErrorType getType() { // return error.getType(); // } // // /** // * Returns the URL to the documentation describing the error. // */ // public String getDocumentationUrl() { // return error.getDocumentationUrl(); // } // // /** // * Returns the ID of the request. This can be used to help the support team find your error // * quickly. // */ // public String getRequestId() { // return error.getRequestId(); // } // // /** // * Returns the HTTP status code. // */ // public int getCode() { // return error.getCode(); // } // // /** // * Returns a list of errors. // */ // public List<ApiError> getErrors() { // return error.getErrors(); // } // // @Override // public String toString() { // return error.toString(); // } // } // // Path: src/main/java/com/gocardless/errors/GoCardlessErrorMapper.java // public class GoCardlessErrorMapper { // /** // * Maps an error response to an exception. // * // * @param error the error response to map // */ // public static GoCardlessApiException toException(ApiErrorResponse error) { // switch (error.getCode()) { // case 401: // return new AuthenticationException(error); // case 403: // return new PermissionException(error); // case 429: // return new RateLimitException(error); // } // switch (error.getType()) { // case GOCARDLESS: // return new GoCardlessInternalException(error); // case INVALID_API_USAGE: // return new InvalidApiUsageException(error); // case INVALID_STATE: // return new InvalidStateException(error); // case VALIDATION_FAILED: // return new ValidationFailedException(error); // } // throw new IllegalStateException("Unknown error type: " + error.getType()); // } // } // // Path: src/main/java/com/gocardless/errors/MalformedResponseException.java // public class MalformedResponseException extends GoCardlessException { // private final String responseBody; // // public MalformedResponseException(String responseBody) { // super("Malformed response received from server"); // this.responseBody = responseBody; // } // // public String getResponseBody() { // return responseBody; // } // } // Path: src/main/java/com/gocardless/http/ResponseParser.java import com.gocardless.errors.ApiErrorResponse; import com.gocardless.errors.GoCardlessApiException; import com.gocardless.errors.GoCardlessErrorMapper; import com.gocardless.errors.MalformedResponseException; import com.google.common.collect.ImmutableList; import com.google.gson.*; import com.google.gson.reflect.TypeToken; import java.util.List; } catch (JsonSyntaxException e) { throw new MalformedResponseException(responseBody); } JsonObject object = json.getAsJsonObject().getAsJsonObject(envelope); return gson.fromJson(object, clazz); } <T> ImmutableList<T> parseMultiple(String responseBody, String envelope, TypeToken<List<T>> clazz) { JsonObject json = new JsonParser().parse(responseBody).getAsJsonObject(); JsonArray array = json.getAsJsonArray(envelope); List<T> items = gson.fromJson(array, clazz.getType()); return ImmutableList.copyOf(items); } <T> ImmutableList<T> parseMultiple(JsonObject json, String envelope, TypeToken<List<T>> clazz) { JsonArray array = json.getAsJsonArray(envelope); List<T> items = gson.fromJson(array, clazz.getType()); return ImmutableList.copyOf(items); } <T> ListResponse<T> parsePage(String responseBody, String envelope, TypeToken<List<T>> clazz) { JsonObject json = new JsonParser().parse(responseBody).getAsJsonObject(); List<T> items = parseMultiple(json, envelope, clazz); JsonObject metaJson = json.getAsJsonObject("meta"); ListResponse.Meta meta = gson.fromJson(metaJson, ListResponse.Meta.class); return new ListResponse<>(ImmutableList.copyOf(items), meta); } GoCardlessApiException parseError(String responseBody) {
ApiErrorResponse error = parseSingle(responseBody, "error", ApiErrorResponse.class);
gocardless/gocardless-pro-java
src/main/java/com/gocardless/http/ResponseParser.java
// Path: src/main/java/com/gocardless/errors/ApiErrorResponse.java // public class ApiErrorResponse { // private static final Joiner JOINER = Joiner.on(", "); // private final String message; // private final ErrorType type; // private final String documentationUrl; // private final String requestId; // private final int code; // private final List<ApiError> errors; // // private ApiErrorResponse(String message, ErrorType type, String documentationUrl, // String requestId, int code, List<ApiError> errors) { // this.message = message; // this.type = type; // this.documentationUrl = documentationUrl; // this.requestId = requestId; // this.code = code; // this.errors = errors; // } // // String getMessage() { // return message; // } // // ErrorType getType() { // return type; // } // // String getDocumentationUrl() { // return documentationUrl; // } // // String getRequestId() { // return requestId; // } // // int getCode() { // return code; // } // // List<ApiError> getErrors() { // if (errors == null) { // return ImmutableList.of(); // } // return ImmutableList.copyOf(errors); // } // // @Override // public String toString() { // if (errors == null || errors.isEmpty()) { // return message; // } else { // return JOINER.join(errors); // } // } // } // // Path: src/main/java/com/gocardless/errors/GoCardlessApiException.java // public class GoCardlessApiException extends GoCardlessException { // private final ApiErrorResponse error; // // GoCardlessApiException(ApiErrorResponse error) { // super(error.toString()); // this.error = error; // } // // /** // * Returns a human-readable description of the error. // */ // public String getErrorMessage() { // return error.getMessage(); // } // // /** // * Returns the type of the error. // */ // public ErrorType getType() { // return error.getType(); // } // // /** // * Returns the URL to the documentation describing the error. // */ // public String getDocumentationUrl() { // return error.getDocumentationUrl(); // } // // /** // * Returns the ID of the request. This can be used to help the support team find your error // * quickly. // */ // public String getRequestId() { // return error.getRequestId(); // } // // /** // * Returns the HTTP status code. // */ // public int getCode() { // return error.getCode(); // } // // /** // * Returns a list of errors. // */ // public List<ApiError> getErrors() { // return error.getErrors(); // } // // @Override // public String toString() { // return error.toString(); // } // } // // Path: src/main/java/com/gocardless/errors/GoCardlessErrorMapper.java // public class GoCardlessErrorMapper { // /** // * Maps an error response to an exception. // * // * @param error the error response to map // */ // public static GoCardlessApiException toException(ApiErrorResponse error) { // switch (error.getCode()) { // case 401: // return new AuthenticationException(error); // case 403: // return new PermissionException(error); // case 429: // return new RateLimitException(error); // } // switch (error.getType()) { // case GOCARDLESS: // return new GoCardlessInternalException(error); // case INVALID_API_USAGE: // return new InvalidApiUsageException(error); // case INVALID_STATE: // return new InvalidStateException(error); // case VALIDATION_FAILED: // return new ValidationFailedException(error); // } // throw new IllegalStateException("Unknown error type: " + error.getType()); // } // } // // Path: src/main/java/com/gocardless/errors/MalformedResponseException.java // public class MalformedResponseException extends GoCardlessException { // private final String responseBody; // // public MalformedResponseException(String responseBody) { // super("Malformed response received from server"); // this.responseBody = responseBody; // } // // public String getResponseBody() { // return responseBody; // } // }
import com.gocardless.errors.ApiErrorResponse; import com.gocardless.errors.GoCardlessApiException; import com.gocardless.errors.GoCardlessErrorMapper; import com.gocardless.errors.MalformedResponseException; import com.google.common.collect.ImmutableList; import com.google.gson.*; import com.google.gson.reflect.TypeToken; import java.util.List;
throw new MalformedResponseException(responseBody); } JsonObject object = json.getAsJsonObject().getAsJsonObject(envelope); return gson.fromJson(object, clazz); } <T> ImmutableList<T> parseMultiple(String responseBody, String envelope, TypeToken<List<T>> clazz) { JsonObject json = new JsonParser().parse(responseBody).getAsJsonObject(); JsonArray array = json.getAsJsonArray(envelope); List<T> items = gson.fromJson(array, clazz.getType()); return ImmutableList.copyOf(items); } <T> ImmutableList<T> parseMultiple(JsonObject json, String envelope, TypeToken<List<T>> clazz) { JsonArray array = json.getAsJsonArray(envelope); List<T> items = gson.fromJson(array, clazz.getType()); return ImmutableList.copyOf(items); } <T> ListResponse<T> parsePage(String responseBody, String envelope, TypeToken<List<T>> clazz) { JsonObject json = new JsonParser().parse(responseBody).getAsJsonObject(); List<T> items = parseMultiple(json, envelope, clazz); JsonObject metaJson = json.getAsJsonObject("meta"); ListResponse.Meta meta = gson.fromJson(metaJson, ListResponse.Meta.class); return new ListResponse<>(ImmutableList.copyOf(items), meta); } GoCardlessApiException parseError(String responseBody) { ApiErrorResponse error = parseSingle(responseBody, "error", ApiErrorResponse.class);
// Path: src/main/java/com/gocardless/errors/ApiErrorResponse.java // public class ApiErrorResponse { // private static final Joiner JOINER = Joiner.on(", "); // private final String message; // private final ErrorType type; // private final String documentationUrl; // private final String requestId; // private final int code; // private final List<ApiError> errors; // // private ApiErrorResponse(String message, ErrorType type, String documentationUrl, // String requestId, int code, List<ApiError> errors) { // this.message = message; // this.type = type; // this.documentationUrl = documentationUrl; // this.requestId = requestId; // this.code = code; // this.errors = errors; // } // // String getMessage() { // return message; // } // // ErrorType getType() { // return type; // } // // String getDocumentationUrl() { // return documentationUrl; // } // // String getRequestId() { // return requestId; // } // // int getCode() { // return code; // } // // List<ApiError> getErrors() { // if (errors == null) { // return ImmutableList.of(); // } // return ImmutableList.copyOf(errors); // } // // @Override // public String toString() { // if (errors == null || errors.isEmpty()) { // return message; // } else { // return JOINER.join(errors); // } // } // } // // Path: src/main/java/com/gocardless/errors/GoCardlessApiException.java // public class GoCardlessApiException extends GoCardlessException { // private final ApiErrorResponse error; // // GoCardlessApiException(ApiErrorResponse error) { // super(error.toString()); // this.error = error; // } // // /** // * Returns a human-readable description of the error. // */ // public String getErrorMessage() { // return error.getMessage(); // } // // /** // * Returns the type of the error. // */ // public ErrorType getType() { // return error.getType(); // } // // /** // * Returns the URL to the documentation describing the error. // */ // public String getDocumentationUrl() { // return error.getDocumentationUrl(); // } // // /** // * Returns the ID of the request. This can be used to help the support team find your error // * quickly. // */ // public String getRequestId() { // return error.getRequestId(); // } // // /** // * Returns the HTTP status code. // */ // public int getCode() { // return error.getCode(); // } // // /** // * Returns a list of errors. // */ // public List<ApiError> getErrors() { // return error.getErrors(); // } // // @Override // public String toString() { // return error.toString(); // } // } // // Path: src/main/java/com/gocardless/errors/GoCardlessErrorMapper.java // public class GoCardlessErrorMapper { // /** // * Maps an error response to an exception. // * // * @param error the error response to map // */ // public static GoCardlessApiException toException(ApiErrorResponse error) { // switch (error.getCode()) { // case 401: // return new AuthenticationException(error); // case 403: // return new PermissionException(error); // case 429: // return new RateLimitException(error); // } // switch (error.getType()) { // case GOCARDLESS: // return new GoCardlessInternalException(error); // case INVALID_API_USAGE: // return new InvalidApiUsageException(error); // case INVALID_STATE: // return new InvalidStateException(error); // case VALIDATION_FAILED: // return new ValidationFailedException(error); // } // throw new IllegalStateException("Unknown error type: " + error.getType()); // } // } // // Path: src/main/java/com/gocardless/errors/MalformedResponseException.java // public class MalformedResponseException extends GoCardlessException { // private final String responseBody; // // public MalformedResponseException(String responseBody) { // super("Malformed response received from server"); // this.responseBody = responseBody; // } // // public String getResponseBody() { // return responseBody; // } // } // Path: src/main/java/com/gocardless/http/ResponseParser.java import com.gocardless.errors.ApiErrorResponse; import com.gocardless.errors.GoCardlessApiException; import com.gocardless.errors.GoCardlessErrorMapper; import com.gocardless.errors.MalformedResponseException; import com.google.common.collect.ImmutableList; import com.google.gson.*; import com.google.gson.reflect.TypeToken; import java.util.List; throw new MalformedResponseException(responseBody); } JsonObject object = json.getAsJsonObject().getAsJsonObject(envelope); return gson.fromJson(object, clazz); } <T> ImmutableList<T> parseMultiple(String responseBody, String envelope, TypeToken<List<T>> clazz) { JsonObject json = new JsonParser().parse(responseBody).getAsJsonObject(); JsonArray array = json.getAsJsonArray(envelope); List<T> items = gson.fromJson(array, clazz.getType()); return ImmutableList.copyOf(items); } <T> ImmutableList<T> parseMultiple(JsonObject json, String envelope, TypeToken<List<T>> clazz) { JsonArray array = json.getAsJsonArray(envelope); List<T> items = gson.fromJson(array, clazz.getType()); return ImmutableList.copyOf(items); } <T> ListResponse<T> parsePage(String responseBody, String envelope, TypeToken<List<T>> clazz) { JsonObject json = new JsonParser().parse(responseBody).getAsJsonObject(); List<T> items = parseMultiple(json, envelope, clazz); JsonObject metaJson = json.getAsJsonObject("meta"); ListResponse.Meta meta = gson.fromJson(metaJson, ListResponse.Meta.class); return new ListResponse<>(ImmutableList.copyOf(items), meta); } GoCardlessApiException parseError(String responseBody) { ApiErrorResponse error = parseSingle(responseBody, "error", ApiErrorResponse.class);
return GoCardlessErrorMapper.toException(error);
gocardless/gocardless-pro-java
src/main/java/com/gocardless/http/HttpClient.java
// Path: src/main/java/com/gocardless/GoCardlessException.java // public abstract class GoCardlessException extends RuntimeException { // protected GoCardlessException() { // super(); // } // // protected GoCardlessException(String message) { // super(message); // } // // protected GoCardlessException(String message, Throwable cause) { // super(message, cause); // } // } // // Path: src/main/java/com/gocardless/errors/GoCardlessInternalException.java // public class GoCardlessInternalException extends GoCardlessApiException { // GoCardlessInternalException(ApiErrorResponse error) { // super(error); // } // }
import static java.util.concurrent.TimeUnit.MILLISECONDS; import com.github.rholder.retry.*; import com.gocardless.GoCardlessException; import com.gocardless.errors.GoCardlessInternalException; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableMap; import com.google.gson.Gson; import java.io.IOException; import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import okhttp3.*;
boolean errorOnIdempotencyConflict) { this.rawClient = rawClient; this.urlFormatter = new UrlFormatter(baseUrl); Gson gson = GsonFactory.build(); this.responseParser = new ResponseParser(gson); this.requestWriter = new RequestWriter(gson); this.credentials = String.format("Bearer %s", accessToken); this.errorOnIdempotencyConflict = errorOnIdempotencyConflict; } public boolean isErrorOnIdempotencyConflict() { return this.errorOnIdempotencyConflict; } <T> T execute(ApiRequest<T> apiRequest) { Request request = buildRequest(apiRequest); Response response = execute(request); return parseResponseBody(apiRequest, response); } <T> ApiResponse<T> executeWrapped(ApiRequest<T> apiRequest) { Request request = buildRequest(apiRequest); Response response = execute(request); T resource = parseResponseBody(apiRequest, response); return new ApiResponse<>(resource, response.code(), response.headers().toMultimap()); } <T> T executeWithRetries(final ApiRequest<T> apiRequest) { Retryer<T> retrier = RetryerBuilder.<T>newBuilder() .retryIfExceptionOfType(GoCardlessNetworkException.class)
// Path: src/main/java/com/gocardless/GoCardlessException.java // public abstract class GoCardlessException extends RuntimeException { // protected GoCardlessException() { // super(); // } // // protected GoCardlessException(String message) { // super(message); // } // // protected GoCardlessException(String message, Throwable cause) { // super(message, cause); // } // } // // Path: src/main/java/com/gocardless/errors/GoCardlessInternalException.java // public class GoCardlessInternalException extends GoCardlessApiException { // GoCardlessInternalException(ApiErrorResponse error) { // super(error); // } // } // Path: src/main/java/com/gocardless/http/HttpClient.java import static java.util.concurrent.TimeUnit.MILLISECONDS; import com.github.rholder.retry.*; import com.gocardless.GoCardlessException; import com.gocardless.errors.GoCardlessInternalException; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableMap; import com.google.gson.Gson; import java.io.IOException; import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import okhttp3.*; boolean errorOnIdempotencyConflict) { this.rawClient = rawClient; this.urlFormatter = new UrlFormatter(baseUrl); Gson gson = GsonFactory.build(); this.responseParser = new ResponseParser(gson); this.requestWriter = new RequestWriter(gson); this.credentials = String.format("Bearer %s", accessToken); this.errorOnIdempotencyConflict = errorOnIdempotencyConflict; } public boolean isErrorOnIdempotencyConflict() { return this.errorOnIdempotencyConflict; } <T> T execute(ApiRequest<T> apiRequest) { Request request = buildRequest(apiRequest); Response response = execute(request); return parseResponseBody(apiRequest, response); } <T> ApiResponse<T> executeWrapped(ApiRequest<T> apiRequest) { Request request = buildRequest(apiRequest); Response response = execute(request); T resource = parseResponseBody(apiRequest, response); return new ApiResponse<>(resource, response.code(), response.headers().toMultimap()); } <T> T executeWithRetries(final ApiRequest<T> apiRequest) { Retryer<T> retrier = RetryerBuilder.<T>newBuilder() .retryIfExceptionOfType(GoCardlessNetworkException.class)
.retryIfExceptionOfType(GoCardlessInternalException.class)
gocardless/gocardless-pro-java
src/main/java/com/gocardless/http/HttpClient.java
// Path: src/main/java/com/gocardless/GoCardlessException.java // public abstract class GoCardlessException extends RuntimeException { // protected GoCardlessException() { // super(); // } // // protected GoCardlessException(String message) { // super(message); // } // // protected GoCardlessException(String message, Throwable cause) { // super(message, cause); // } // } // // Path: src/main/java/com/gocardless/errors/GoCardlessInternalException.java // public class GoCardlessInternalException extends GoCardlessApiException { // GoCardlessInternalException(ApiErrorResponse error) { // super(error); // } // }
import static java.util.concurrent.TimeUnit.MILLISECONDS; import com.github.rholder.retry.*; import com.gocardless.GoCardlessException; import com.gocardless.errors.GoCardlessInternalException; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableMap; import com.google.gson.Gson; import java.io.IOException; import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import okhttp3.*;
} else { return EMPTY_BODY; } } String json = requestWriter.write(request, request.getRequestEnvelope()); return RequestBody.create(MEDIA_TYPE, json); } private Response execute(Request request) { Response response; try { response = rawClient.newCall(request).execute(); } catch (IOException e) { throw new GoCardlessNetworkException("Failed to execute request", e); } if (!response.isSuccessful()) { throw handleErrorResponse(response); } return response; } private <T> T parseResponseBody(ApiRequest<T> request, Response response) { try { String responseBody = response.body().string(); return request.parseResponse(responseBody, responseParser); } catch (IOException e) { throw new GoCardlessNetworkException("Failed to read response body", e); } }
// Path: src/main/java/com/gocardless/GoCardlessException.java // public abstract class GoCardlessException extends RuntimeException { // protected GoCardlessException() { // super(); // } // // protected GoCardlessException(String message) { // super(message); // } // // protected GoCardlessException(String message, Throwable cause) { // super(message, cause); // } // } // // Path: src/main/java/com/gocardless/errors/GoCardlessInternalException.java // public class GoCardlessInternalException extends GoCardlessApiException { // GoCardlessInternalException(ApiErrorResponse error) { // super(error); // } // } // Path: src/main/java/com/gocardless/http/HttpClient.java import static java.util.concurrent.TimeUnit.MILLISECONDS; import com.github.rholder.retry.*; import com.gocardless.GoCardlessException; import com.gocardless.errors.GoCardlessInternalException; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableMap; import com.google.gson.Gson; import java.io.IOException; import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import okhttp3.*; } else { return EMPTY_BODY; } } String json = requestWriter.write(request, request.getRequestEnvelope()); return RequestBody.create(MEDIA_TYPE, json); } private Response execute(Request request) { Response response; try { response = rawClient.newCall(request).execute(); } catch (IOException e) { throw new GoCardlessNetworkException("Failed to execute request", e); } if (!response.isSuccessful()) { throw handleErrorResponse(response); } return response; } private <T> T parseResponseBody(ApiRequest<T> request, Response response) { try { String responseBody = response.body().string(); return request.parseResponse(responseBody, responseParser); } catch (IOException e) { throw new GoCardlessNetworkException("Failed to read response body", e); } }
private GoCardlessException handleErrorResponse(Response response) {
gocardless/gocardless-pro-java
src/main/java/com/gocardless/services/CurrencyExchangeRateService.java
// Path: src/main/java/com/gocardless/resources/CurrencyExchangeRate.java // public class CurrencyExchangeRate { // private CurrencyExchangeRate() { // // blank to prevent instantiation // } // // private String rate; // private String source; // private String target; // private String time; // // /** // * The exchange rate from the source to target currencies provided with up to 10 decimal places. // */ // public String getRate() { // return rate; // } // // /** // * Source currency // */ // public String getSource() { // return source; // } // // /** // * Target currency // */ // public String getTarget() { // return target; // } // // /** // * Time at which the rate was retrieved from the provider. // */ // public String getTime() { // return time; // } // }
import com.gocardless.http.*; import com.gocardless.resources.CurrencyExchangeRate; import com.google.common.collect.ImmutableMap; import com.google.gson.reflect.TypeToken; import java.util.List; import java.util.Map;
package com.gocardless.services; /** * Service class for working with currency exchange rate resources. * * Currency exchange rates from our foreign exchange provider. */ public class CurrencyExchangeRateService { private final HttpClient httpClient; /** * Constructor. Users of this library should have no need to call this - an instance of this * class can be obtained by calling * {@link com.gocardless.GoCardlessClient#currencyExchangeRates() }. */ public CurrencyExchangeRateService(HttpClient httpClient) { this.httpClient = httpClient; } /** * Returns a [cursor-paginated](#api-usage-cursor-pagination) list of all exchange rates. */
// Path: src/main/java/com/gocardless/resources/CurrencyExchangeRate.java // public class CurrencyExchangeRate { // private CurrencyExchangeRate() { // // blank to prevent instantiation // } // // private String rate; // private String source; // private String target; // private String time; // // /** // * The exchange rate from the source to target currencies provided with up to 10 decimal places. // */ // public String getRate() { // return rate; // } // // /** // * Source currency // */ // public String getSource() { // return source; // } // // /** // * Target currency // */ // public String getTarget() { // return target; // } // // /** // * Time at which the rate was retrieved from the provider. // */ // public String getTime() { // return time; // } // } // Path: src/main/java/com/gocardless/services/CurrencyExchangeRateService.java import com.gocardless.http.*; import com.gocardless.resources.CurrencyExchangeRate; import com.google.common.collect.ImmutableMap; import com.google.gson.reflect.TypeToken; import java.util.List; import java.util.Map; package com.gocardless.services; /** * Service class for working with currency exchange rate resources. * * Currency exchange rates from our foreign exchange provider. */ public class CurrencyExchangeRateService { private final HttpClient httpClient; /** * Constructor. Users of this library should have no need to call this - an instance of this * class can be obtained by calling * {@link com.gocardless.GoCardlessClient#currencyExchangeRates() }. */ public CurrencyExchangeRateService(HttpClient httpClient) { this.httpClient = httpClient; } /** * Returns a [cursor-paginated](#api-usage-cursor-pagination) list of all exchange rates. */
public CurrencyExchangeRateListRequest<ListResponse<CurrencyExchangeRate>> list() {
gocardless/gocardless-pro-java
src/main/java/com/gocardless/services/CreditorBankAccountService.java
// Path: src/main/java/com/gocardless/resources/CreditorBankAccount.java // public class CreditorBankAccount { // private CreditorBankAccount() { // // blank to prevent instantiation // } // // private String accountHolderName; // private String accountNumberEnding; // private AccountType accountType; // private String bankName; // private String countryCode; // private String createdAt; // private String currency; // private Boolean enabled; // private String id; // private Links links; // private Map<String, String> metadata; // // /** // * Name of the account holder, as known by the bank. Usually this is the same as the name stored // * with the linked [creditor](#core-endpoints-creditors). This field will be transliterated, // * upcased and truncated to 18 characters. // */ // public String getAccountHolderName() { // return accountHolderName; // } // // /** // * The last few digits of the account number. Currently 4 digits for NZD bank accounts and 2 // * digits for other currencies. // */ // public String getAccountNumberEnding() { // return accountNumberEnding; // } // // /** // * Bank account type. Required for USD-denominated bank accounts. Must not be provided for bank // * accounts in other currencies. See [local details](#local-bank-details-united-states) for more // * information. // */ // public AccountType getAccountType() { // return accountType; // } // // /** // * Name of bank, taken from the bank details. // */ // public String getBankName() { // return bankName; // } // // /** // * [ISO 3166-1 alpha-2 // * code](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements). // * Defaults to the country code of the `iban` if supplied, otherwise is required. // */ // public String getCountryCode() { // return countryCode; // } // // /** // * Fixed [timestamp](#api-usage-time-zones--dates), recording when this resource was created. // */ // public String getCreatedAt() { // return createdAt; // } // // /** // * [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217#Active_codes) currency code. Currently // * "AUD", "CAD", "DKK", "EUR", "GBP", "NZD", "SEK" and "USD" are supported. // */ // public String getCurrency() { // return currency; // } // // /** // * Boolean value showing whether the bank account is enabled or disabled. // */ // public Boolean getEnabled() { // return enabled; // } // // /** // * Unique identifier, beginning with "BA". // */ // public String getId() { // return id; // } // // public Links getLinks() { // return links; // } // // /** // * Key-value store of custom data. Up to 3 keys are permitted, with key names up to 50 // * characters and values up to 500 characters. // */ // public Map<String, String> getMetadata() { // return metadata; // } // // public enum AccountType { // @SerializedName("savings") // SAVINGS, @SerializedName("checking") // CHECKING, @SerializedName("unknown") // UNKNOWN // } // // public static class Links { // private Links() { // // blank to prevent instantiation // } // // private String creditor; // // /** // * ID of the [creditor](#core-endpoints-creditors) that owns this bank account. // */ // public String getCreditor() { // return creditor; // } // } // }
import com.gocardless.http.*; import com.gocardless.resources.CreditorBankAccount; import com.google.common.collect.ImmutableMap; import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; import java.util.HashMap; import java.util.List; import java.util.Map;
package com.gocardless.services; /** * Service class for working with creditor bank account resources. * * Creditor Bank Accounts hold the bank details of a [creditor](#core-endpoints-creditors). These * are the bank accounts which your [payouts](#core-endpoints-payouts) will be sent to. * * Note that creditor bank accounts must be unique, and so you will encounter a * `bank_account_exists` error if you try to create a duplicate bank account. You may wish to handle * this by updating the existing record instead, the ID of which will be provided as * `links[creditor_bank_account]` in the error response. * * <p class="restricted-notice"> * <strong>Restricted</strong>: This API is not available for partner integrations. * </p> */ public class CreditorBankAccountService { private final HttpClient httpClient; /** * Constructor. Users of this library should have no need to call this - an instance of this * class can be obtained by calling * {@link com.gocardless.GoCardlessClient#creditorBankAccounts() }. */ public CreditorBankAccountService(HttpClient httpClient) { this.httpClient = httpClient; } /** * Creates a new creditor bank account object. */ public CreditorBankAccountCreateRequest create() { return new CreditorBankAccountCreateRequest(httpClient); } /** * Returns a [cursor-paginated](#api-usage-cursor-pagination) list of your creditor bank * accounts. */
// Path: src/main/java/com/gocardless/resources/CreditorBankAccount.java // public class CreditorBankAccount { // private CreditorBankAccount() { // // blank to prevent instantiation // } // // private String accountHolderName; // private String accountNumberEnding; // private AccountType accountType; // private String bankName; // private String countryCode; // private String createdAt; // private String currency; // private Boolean enabled; // private String id; // private Links links; // private Map<String, String> metadata; // // /** // * Name of the account holder, as known by the bank. Usually this is the same as the name stored // * with the linked [creditor](#core-endpoints-creditors). This field will be transliterated, // * upcased and truncated to 18 characters. // */ // public String getAccountHolderName() { // return accountHolderName; // } // // /** // * The last few digits of the account number. Currently 4 digits for NZD bank accounts and 2 // * digits for other currencies. // */ // public String getAccountNumberEnding() { // return accountNumberEnding; // } // // /** // * Bank account type. Required for USD-denominated bank accounts. Must not be provided for bank // * accounts in other currencies. See [local details](#local-bank-details-united-states) for more // * information. // */ // public AccountType getAccountType() { // return accountType; // } // // /** // * Name of bank, taken from the bank details. // */ // public String getBankName() { // return bankName; // } // // /** // * [ISO 3166-1 alpha-2 // * code](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements). // * Defaults to the country code of the `iban` if supplied, otherwise is required. // */ // public String getCountryCode() { // return countryCode; // } // // /** // * Fixed [timestamp](#api-usage-time-zones--dates), recording when this resource was created. // */ // public String getCreatedAt() { // return createdAt; // } // // /** // * [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217#Active_codes) currency code. Currently // * "AUD", "CAD", "DKK", "EUR", "GBP", "NZD", "SEK" and "USD" are supported. // */ // public String getCurrency() { // return currency; // } // // /** // * Boolean value showing whether the bank account is enabled or disabled. // */ // public Boolean getEnabled() { // return enabled; // } // // /** // * Unique identifier, beginning with "BA". // */ // public String getId() { // return id; // } // // public Links getLinks() { // return links; // } // // /** // * Key-value store of custom data. Up to 3 keys are permitted, with key names up to 50 // * characters and values up to 500 characters. // */ // public Map<String, String> getMetadata() { // return metadata; // } // // public enum AccountType { // @SerializedName("savings") // SAVINGS, @SerializedName("checking") // CHECKING, @SerializedName("unknown") // UNKNOWN // } // // public static class Links { // private Links() { // // blank to prevent instantiation // } // // private String creditor; // // /** // * ID of the [creditor](#core-endpoints-creditors) that owns this bank account. // */ // public String getCreditor() { // return creditor; // } // } // } // Path: src/main/java/com/gocardless/services/CreditorBankAccountService.java import com.gocardless.http.*; import com.gocardless.resources.CreditorBankAccount; import com.google.common.collect.ImmutableMap; import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; import java.util.HashMap; import java.util.List; import java.util.Map; package com.gocardless.services; /** * Service class for working with creditor bank account resources. * * Creditor Bank Accounts hold the bank details of a [creditor](#core-endpoints-creditors). These * are the bank accounts which your [payouts](#core-endpoints-payouts) will be sent to. * * Note that creditor bank accounts must be unique, and so you will encounter a * `bank_account_exists` error if you try to create a duplicate bank account. You may wish to handle * this by updating the existing record instead, the ID of which will be provided as * `links[creditor_bank_account]` in the error response. * * <p class="restricted-notice"> * <strong>Restricted</strong>: This API is not available for partner integrations. * </p> */ public class CreditorBankAccountService { private final HttpClient httpClient; /** * Constructor. Users of this library should have no need to call this - an instance of this * class can be obtained by calling * {@link com.gocardless.GoCardlessClient#creditorBankAccounts() }. */ public CreditorBankAccountService(HttpClient httpClient) { this.httpClient = httpClient; } /** * Creates a new creditor bank account object. */ public CreditorBankAccountCreateRequest create() { return new CreditorBankAccountCreateRequest(httpClient); } /** * Returns a [cursor-paginated](#api-usage-cursor-pagination) list of your creditor bank * accounts. */
public CreditorBankAccountListRequest<ListResponse<CreditorBankAccount>> list() {
gocardless/gocardless-pro-java
src/test/java/com/gocardless/http/ResponseParserTest.java
// Path: src/main/java/com/gocardless/errors/ErrorType.java // public enum ErrorType { // /** // * An internal error occurred while processing your request. This should be reported to our // * support team with the id, so we can resolve the issue. // */ // @SerializedName("gocardless") // GOCARDLESS, // /** // * This is an error with the request you made. It could be an invalid URL, the authentication // * header could be missing, invalid, or grant insufficient permissions, you may have reached // * your rate limit, or the syntax of your request could be incorrect. The errors will give more // * detail of the specific issue. // */ // @SerializedName("invalid_api_usage") // INVALID_API_USAGE, // /** // * The action you are trying to perform is invalid due to the state of the resource you are // * requesting it on. For example, a payment you are trying to cancel might already have been // * submitted. The errors will give more details. // */ // @SerializedName("invalid_state") // INVALID_STATE, // /** // * The parameters submitted with your request were invalid. Details of which fields were invalid // * and why are included in the response. // */ // @SerializedName("validation_failed") // VALIDATION_FAILED // } // // Path: src/test/java/com/gocardless/http/HttpTestUtil.java // public static class DummyItem { // public String stringField; // public int intField; // }
import static com.gocardless.errors.ErrorType.*; import static com.google.common.base.Charsets.UTF_8; import static org.assertj.core.api.Assertions.assertThat; import com.gocardless.errors.*; import com.gocardless.http.HttpTestUtil.DummyItem; import com.google.common.collect.ImmutableList; import com.google.common.io.Resources; import com.google.gson.reflect.TypeToken; import java.io.IOException; import java.net.URL; import java.util.List; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException;
package com.gocardless.http; public class ResponseParserTest { private ResponseParser parser; @Rule public final ExpectedException exception = ExpectedException.none(); @Before public void setUp() { parser = new ResponseParser(GsonFactory.build()); } @Test public void shouldParseSingle() throws IOException { URL resource = Resources.getResource("fixtures/single.json"); String responseBody = Resources.toString(resource, UTF_8);
// Path: src/main/java/com/gocardless/errors/ErrorType.java // public enum ErrorType { // /** // * An internal error occurred while processing your request. This should be reported to our // * support team with the id, so we can resolve the issue. // */ // @SerializedName("gocardless") // GOCARDLESS, // /** // * This is an error with the request you made. It could be an invalid URL, the authentication // * header could be missing, invalid, or grant insufficient permissions, you may have reached // * your rate limit, or the syntax of your request could be incorrect. The errors will give more // * detail of the specific issue. // */ // @SerializedName("invalid_api_usage") // INVALID_API_USAGE, // /** // * The action you are trying to perform is invalid due to the state of the resource you are // * requesting it on. For example, a payment you are trying to cancel might already have been // * submitted. The errors will give more details. // */ // @SerializedName("invalid_state") // INVALID_STATE, // /** // * The parameters submitted with your request were invalid. Details of which fields were invalid // * and why are included in the response. // */ // @SerializedName("validation_failed") // VALIDATION_FAILED // } // // Path: src/test/java/com/gocardless/http/HttpTestUtil.java // public static class DummyItem { // public String stringField; // public int intField; // } // Path: src/test/java/com/gocardless/http/ResponseParserTest.java import static com.gocardless.errors.ErrorType.*; import static com.google.common.base.Charsets.UTF_8; import static org.assertj.core.api.Assertions.assertThat; import com.gocardless.errors.*; import com.gocardless.http.HttpTestUtil.DummyItem; import com.google.common.collect.ImmutableList; import com.google.common.io.Resources; import com.google.gson.reflect.TypeToken; import java.io.IOException; import java.net.URL; import java.util.List; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; package com.gocardless.http; public class ResponseParserTest { private ResponseParser parser; @Rule public final ExpectedException exception = ExpectedException.none(); @Before public void setUp() { parser = new ResponseParser(GsonFactory.build()); } @Test public void shouldParseSingle() throws IOException { URL resource = Resources.getResource("fixtures/single.json"); String responseBody = Resources.toString(resource, UTF_8);
DummyItem result = parser.parseSingle(responseBody, "items", DummyItem.class);
gocardless/gocardless-pro-java
src/test/java/com/gocardless/http/ArrayRequestTest.java
// Path: src/test/java/com/gocardless/http/HttpTestUtil.java // public static class DummyItem { // public String stringField; // public int intField; // }
import static org.assertj.core.api.Assertions.assertThat; import com.gocardless.http.HttpTestUtil.DummyItem; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.gson.reflect.TypeToken; import java.util.List; import org.junit.Rule; import org.junit.Test;
package com.gocardless.http; public class ArrayRequestTest { @Rule public final MockHttp http = new MockHttp(); @Test public void shouldPerformArrayRequest() throws Exception { http.enqueueResponse(200, "fixtures/array.json");
// Path: src/test/java/com/gocardless/http/HttpTestUtil.java // public static class DummyItem { // public String stringField; // public int intField; // } // Path: src/test/java/com/gocardless/http/ArrayRequestTest.java import static org.assertj.core.api.Assertions.assertThat; import com.gocardless.http.HttpTestUtil.DummyItem; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.gson.reflect.TypeToken; import java.util.List; import org.junit.Rule; import org.junit.Test; package com.gocardless.http; public class ArrayRequestTest { @Rule public final MockHttp http = new MockHttp(); @Test public void shouldPerformArrayRequest() throws Exception { http.enqueueResponse(200, "fixtures/array.json");
ImmutableList<DummyItem> result = new DummyArrayRequest().execute();
gocardless/gocardless-pro-java
src/main/java/com/gocardless/services/BankDetailsLookupService.java
// Path: src/main/java/com/gocardless/resources/BankDetailsLookup.java // public class BankDetailsLookup { // private BankDetailsLookup() { // // blank to prevent instantiation // } // // private List<AvailableDebitScheme> availableDebitSchemes; // private String bankName; // private String bic; // // /** // * Array of [schemes](#mandates_scheme) supported for this bank account. This will be an empty // * array if the bank account is not reachable by any schemes. // */ // public List<AvailableDebitScheme> getAvailableDebitSchemes() { // return availableDebitSchemes; // } // // /** // * The name of the bank with which the account is held (if available). // */ // public String getBankName() { // return bankName; // } // // /** // * ISO 9362 SWIFT BIC of the bank with which the account is held. // * // * <p class="notice"> // * Even if no BIC is returned for an account, GoCardless may still be able to collect payments // * from it - you should refer to the `available_debit_schemes` attribute to determine // * reachability. // * </p> // */ // public String getBic() { // return bic; // } // // public enum AvailableDebitScheme { // @SerializedName("ach") // ACH, @SerializedName("autogiro") // AUTOGIRO, @SerializedName("bacs") // BACS, @SerializedName("becs") // BECS, @SerializedName("becs_nz") // BECS_NZ, @SerializedName("betalingsservice") // BETALINGSSERVICE, @SerializedName("pad") // PAD, @SerializedName("sepa_core") // SEPA_CORE, @SerializedName("unknown") // UNKNOWN // } // }
import com.gocardless.http.*; import com.gocardless.resources.BankDetailsLookup;
package com.gocardless.services; /** * Service class for working with bank details lookup resources. * * Look up the name and reachability of a bank account. */ public class BankDetailsLookupService { private final HttpClient httpClient; /** * Constructor. Users of this library should have no need to call this - an instance of this * class can be obtained by calling * {@link com.gocardless.GoCardlessClient#bankDetailsLookups() }. */ public BankDetailsLookupService(HttpClient httpClient) { this.httpClient = httpClient; } /** * Performs a bank details lookup. As part of the lookup, a modulus check and reachability check * are performed. * * If your request returns an [error](#api-usage-errors) or the `available_debit_schemes` * attribute is an empty array, you will not be able to collect payments from the specified bank * account. GoCardless may be able to collect payments from an account even if no `bic` is * returned. * * Bank account details may be supplied using [local details](#appendix-local-bank-details) or * an IBAN. * * _Note:_ Usage of this endpoint is monitored. If your organisation relies on GoCardless for * modulus or reachability checking but not for payment collection, please get in touch. */ public BankDetailsLookupCreateRequest create() { return new BankDetailsLookupCreateRequest(httpClient); } /** * Request class for {@link BankDetailsLookupService#create }. * * Performs a bank details lookup. As part of the lookup, a modulus check and reachability check * are performed. * * If your request returns an [error](#api-usage-errors) or the `available_debit_schemes` * attribute is an empty array, you will not be able to collect payments from the specified bank * account. GoCardless may be able to collect payments from an account even if no `bic` is * returned. * * Bank account details may be supplied using [local details](#appendix-local-bank-details) or * an IBAN. * * _Note:_ Usage of this endpoint is monitored. If your organisation relies on GoCardless for * modulus or reachability checking but not for payment collection, please get in touch. */ public static final class BankDetailsLookupCreateRequest
// Path: src/main/java/com/gocardless/resources/BankDetailsLookup.java // public class BankDetailsLookup { // private BankDetailsLookup() { // // blank to prevent instantiation // } // // private List<AvailableDebitScheme> availableDebitSchemes; // private String bankName; // private String bic; // // /** // * Array of [schemes](#mandates_scheme) supported for this bank account. This will be an empty // * array if the bank account is not reachable by any schemes. // */ // public List<AvailableDebitScheme> getAvailableDebitSchemes() { // return availableDebitSchemes; // } // // /** // * The name of the bank with which the account is held (if available). // */ // public String getBankName() { // return bankName; // } // // /** // * ISO 9362 SWIFT BIC of the bank with which the account is held. // * // * <p class="notice"> // * Even if no BIC is returned for an account, GoCardless may still be able to collect payments // * from it - you should refer to the `available_debit_schemes` attribute to determine // * reachability. // * </p> // */ // public String getBic() { // return bic; // } // // public enum AvailableDebitScheme { // @SerializedName("ach") // ACH, @SerializedName("autogiro") // AUTOGIRO, @SerializedName("bacs") // BACS, @SerializedName("becs") // BECS, @SerializedName("becs_nz") // BECS_NZ, @SerializedName("betalingsservice") // BETALINGSSERVICE, @SerializedName("pad") // PAD, @SerializedName("sepa_core") // SEPA_CORE, @SerializedName("unknown") // UNKNOWN // } // } // Path: src/main/java/com/gocardless/services/BankDetailsLookupService.java import com.gocardless.http.*; import com.gocardless.resources.BankDetailsLookup; package com.gocardless.services; /** * Service class for working with bank details lookup resources. * * Look up the name and reachability of a bank account. */ public class BankDetailsLookupService { private final HttpClient httpClient; /** * Constructor. Users of this library should have no need to call this - an instance of this * class can be obtained by calling * {@link com.gocardless.GoCardlessClient#bankDetailsLookups() }. */ public BankDetailsLookupService(HttpClient httpClient) { this.httpClient = httpClient; } /** * Performs a bank details lookup. As part of the lookup, a modulus check and reachability check * are performed. * * If your request returns an [error](#api-usage-errors) or the `available_debit_schemes` * attribute is an empty array, you will not be able to collect payments from the specified bank * account. GoCardless may be able to collect payments from an account even if no `bic` is * returned. * * Bank account details may be supplied using [local details](#appendix-local-bank-details) or * an IBAN. * * _Note:_ Usage of this endpoint is monitored. If your organisation relies on GoCardless for * modulus or reachability checking but not for payment collection, please get in touch. */ public BankDetailsLookupCreateRequest create() { return new BankDetailsLookupCreateRequest(httpClient); } /** * Request class for {@link BankDetailsLookupService#create }. * * Performs a bank details lookup. As part of the lookup, a modulus check and reachability check * are performed. * * If your request returns an [error](#api-usage-errors) or the `available_debit_schemes` * attribute is an empty array, you will not be able to collect payments from the specified bank * account. GoCardless may be able to collect payments from an account even if no `bic` is * returned. * * Bank account details may be supplied using [local details](#appendix-local-bank-details) or * an IBAN. * * _Note:_ Usage of this endpoint is monitored. If your organisation relies on GoCardless for * modulus or reachability checking but not for payment collection, please get in touch. */ public static final class BankDetailsLookupCreateRequest
extends PostRequest<BankDetailsLookup> {
gocardless/gocardless-pro-java
src/test/java/com/gocardless/http/IdempotentPostRequestTest.java
// Path: src/main/java/com/gocardless/errors/ValidationFailedException.java // public class ValidationFailedException extends GoCardlessApiException { // ValidationFailedException(ApiErrorResponse error) { // super(error); // } // }
import static org.assertj.core.api.Assertions.assertThat; import com.gocardless.errors.ValidationFailedException; import com.google.common.collect.ImmutableMap; import java.util.Map; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException;
new DummyPostRequest().withHeader("Accept-Language", "fr-FR").execute(); assertThat(result.stringField).isEqualTo("foo"); assertThat(result.intField).isEqualTo(123); http.takeRequest(); // This tests that we send our headers on the retry. http.assertRequestMade("POST", "/dummy", "fixtures/single.json", ImmutableMap.of("Authorization", "Bearer token")); } @Test public void shouldHandleConflictByPerformingGet() throws Exception { http.enqueueNetworkFailure(); http.enqueueResponse(409, "fixtures/conflict.json"); http.enqueueResponse(200, "fixtures/single.json"); HttpTestUtil.DummyItem result = new DummyPostRequest().withHeader("Accept-Language", "fr-FR").execute(); assertThat(result.stringField).isEqualTo("foo"); assertThat(result.intField).isEqualTo(123); http.takeRequest(); // This tests that we send our headers on the retry. http.assertRequestMade("POST", "/dummy", "fixtures/single.json", ImmutableMap.of("Authorization", "Bearer token", "Accept-Language", "fr-FR")); http.assertRequestMade("GET", "/dummy/ID123", ImmutableMap.of("Authorization", "Bearer token", "Accept-Language", "fr-FR")); } @Test public void shouldPropagateExceptionForNonConflictError() throws Exception { http.enqueueResponse(422, "fixtures/validation_failed.json"); DummyPostRequest request = new DummyPostRequest();
// Path: src/main/java/com/gocardless/errors/ValidationFailedException.java // public class ValidationFailedException extends GoCardlessApiException { // ValidationFailedException(ApiErrorResponse error) { // super(error); // } // } // Path: src/test/java/com/gocardless/http/IdempotentPostRequestTest.java import static org.assertj.core.api.Assertions.assertThat; import com.gocardless.errors.ValidationFailedException; import com.google.common.collect.ImmutableMap; import java.util.Map; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; new DummyPostRequest().withHeader("Accept-Language", "fr-FR").execute(); assertThat(result.stringField).isEqualTo("foo"); assertThat(result.intField).isEqualTo(123); http.takeRequest(); // This tests that we send our headers on the retry. http.assertRequestMade("POST", "/dummy", "fixtures/single.json", ImmutableMap.of("Authorization", "Bearer token")); } @Test public void shouldHandleConflictByPerformingGet() throws Exception { http.enqueueNetworkFailure(); http.enqueueResponse(409, "fixtures/conflict.json"); http.enqueueResponse(200, "fixtures/single.json"); HttpTestUtil.DummyItem result = new DummyPostRequest().withHeader("Accept-Language", "fr-FR").execute(); assertThat(result.stringField).isEqualTo("foo"); assertThat(result.intField).isEqualTo(123); http.takeRequest(); // This tests that we send our headers on the retry. http.assertRequestMade("POST", "/dummy", "fixtures/single.json", ImmutableMap.of("Authorization", "Bearer token", "Accept-Language", "fr-FR")); http.assertRequestMade("GET", "/dummy/ID123", ImmutableMap.of("Authorization", "Bearer token", "Accept-Language", "fr-FR")); } @Test public void shouldPropagateExceptionForNonConflictError() throws Exception { http.enqueueResponse(422, "fixtures/validation_failed.json"); DummyPostRequest request = new DummyPostRequest();
exception.expect(ValidationFailedException.class);
gocardless/gocardless-pro-java
src/main/java/com/gocardless/services/BankAuthorisationService.java
// Path: src/main/java/com/gocardless/resources/BankAuthorisation.java // public class BankAuthorisation { // private BankAuthorisation() { // // blank to prevent instantiation // } // // private AuthorisationType authorisationType; // private String authorisedAt; // private String createdAt; // private String expiresAt; // private String id; // private String lastVisitedAt; // private Links links; // private String redirectUri; // private String url; // // /** // * Type of authorisation, can be either 'mandate' or 'payment'. // */ // public AuthorisationType getAuthorisationType() { // return authorisationType; // } // // /** // * Fixed [timestamp](#api-usage-time-zones--dates), recording when the user has been authorised. // */ // public String getAuthorisedAt() { // return authorisedAt; // } // // /** // * Timestamp when the flow was created // */ // public String getCreatedAt() { // return createdAt; // } // // /** // * Timestamp when the url will expire. Each authorisation url currently lasts for 15 minutes, // * but this can vary by bank. // */ // public String getExpiresAt() { // return expiresAt; // } // // /** // * Unique identifier, beginning with "BAU". // */ // public String getId() { // return id; // } // // /** // * Fixed [timestamp](#api-usage-time-zones--dates), recording when the authorisation URL has // * been visited. // */ // public String getLastVisitedAt() { // return lastVisitedAt; // } // // public Links getLinks() { // return links; // } // // /** // * URL that the payer can be redirected to after authorising the payment. // */ // public String getRedirectUri() { // return redirectUri; // } // // /** // * URL for an oauth flow that will allow the user to authorise the payment // */ // public String getUrl() { // return url; // } // // public enum AuthorisationType { // @SerializedName("mandate") // MANDATE, @SerializedName("payment") // PAYMENT, @SerializedName("unknown") // UNKNOWN // } // // public static class Links { // private Links() { // // blank to prevent instantiation // } // // private String billingRequest; // private String institution; // // /** // * ID of the [billing request](#billing-requests-billing-requests) against which this // * authorisation was created. // */ // public String getBillingRequest() { // return billingRequest; // } // // /** // * ID of the [institution](#billing-requests-institutions) against which this authorisation // * was created. // */ // public String getInstitution() { // return institution; // } // } // }
import com.gocardless.http.*; import com.gocardless.resources.BankAuthorisation; import com.google.common.collect.ImmutableMap; import java.util.Map;
package com.gocardless.services; /** * Service class for working with bank authorisation resources. * * Bank Authorisations can be used to authorise Billing Requests. Authorisations are created against * a specific bank, usually the bank that provides the payer's account. * * Creation of Bank Authorisations is only permitted from GoCardless hosted UIs (see Billing Request * Flows) to ensure we meet regulatory requirements for checkout flows. */ public class BankAuthorisationService { private final HttpClient httpClient; /** * Constructor. Users of this library should have no need to call this - an instance of this * class can be obtained by calling * {@link com.gocardless.GoCardlessClient#bankAuthorisations() }. */ public BankAuthorisationService(HttpClient httpClient) { this.httpClient = httpClient; } /** * Fetches a bank authorisation */ public BankAuthorisationGetRequest get(String identity) { return new BankAuthorisationGetRequest(httpClient, identity); } /** * Create a Bank Authorisation. */ public BankAuthorisationCreateRequest create() { return new BankAuthorisationCreateRequest(httpClient); } /** * Request class for {@link BankAuthorisationService#get }. * * Fetches a bank authorisation */
// Path: src/main/java/com/gocardless/resources/BankAuthorisation.java // public class BankAuthorisation { // private BankAuthorisation() { // // blank to prevent instantiation // } // // private AuthorisationType authorisationType; // private String authorisedAt; // private String createdAt; // private String expiresAt; // private String id; // private String lastVisitedAt; // private Links links; // private String redirectUri; // private String url; // // /** // * Type of authorisation, can be either 'mandate' or 'payment'. // */ // public AuthorisationType getAuthorisationType() { // return authorisationType; // } // // /** // * Fixed [timestamp](#api-usage-time-zones--dates), recording when the user has been authorised. // */ // public String getAuthorisedAt() { // return authorisedAt; // } // // /** // * Timestamp when the flow was created // */ // public String getCreatedAt() { // return createdAt; // } // // /** // * Timestamp when the url will expire. Each authorisation url currently lasts for 15 minutes, // * but this can vary by bank. // */ // public String getExpiresAt() { // return expiresAt; // } // // /** // * Unique identifier, beginning with "BAU". // */ // public String getId() { // return id; // } // // /** // * Fixed [timestamp](#api-usage-time-zones--dates), recording when the authorisation URL has // * been visited. // */ // public String getLastVisitedAt() { // return lastVisitedAt; // } // // public Links getLinks() { // return links; // } // // /** // * URL that the payer can be redirected to after authorising the payment. // */ // public String getRedirectUri() { // return redirectUri; // } // // /** // * URL for an oauth flow that will allow the user to authorise the payment // */ // public String getUrl() { // return url; // } // // public enum AuthorisationType { // @SerializedName("mandate") // MANDATE, @SerializedName("payment") // PAYMENT, @SerializedName("unknown") // UNKNOWN // } // // public static class Links { // private Links() { // // blank to prevent instantiation // } // // private String billingRequest; // private String institution; // // /** // * ID of the [billing request](#billing-requests-billing-requests) against which this // * authorisation was created. // */ // public String getBillingRequest() { // return billingRequest; // } // // /** // * ID of the [institution](#billing-requests-institutions) against which this authorisation // * was created. // */ // public String getInstitution() { // return institution; // } // } // } // Path: src/main/java/com/gocardless/services/BankAuthorisationService.java import com.gocardless.http.*; import com.gocardless.resources.BankAuthorisation; import com.google.common.collect.ImmutableMap; import java.util.Map; package com.gocardless.services; /** * Service class for working with bank authorisation resources. * * Bank Authorisations can be used to authorise Billing Requests. Authorisations are created against * a specific bank, usually the bank that provides the payer's account. * * Creation of Bank Authorisations is only permitted from GoCardless hosted UIs (see Billing Request * Flows) to ensure we meet regulatory requirements for checkout flows. */ public class BankAuthorisationService { private final HttpClient httpClient; /** * Constructor. Users of this library should have no need to call this - an instance of this * class can be obtained by calling * {@link com.gocardless.GoCardlessClient#bankAuthorisations() }. */ public BankAuthorisationService(HttpClient httpClient) { this.httpClient = httpClient; } /** * Fetches a bank authorisation */ public BankAuthorisationGetRequest get(String identity) { return new BankAuthorisationGetRequest(httpClient, identity); } /** * Create a Bank Authorisation. */ public BankAuthorisationCreateRequest create() { return new BankAuthorisationCreateRequest(httpClient); } /** * Request class for {@link BankAuthorisationService#get }. * * Fetches a bank authorisation */
public static final class BankAuthorisationGetRequest extends GetRequest<BankAuthorisation> {
gocardless/gocardless-pro-java
src/main/java/com/gocardless/services/CustomerNotificationService.java
// Path: src/main/java/com/gocardless/resources/CustomerNotification.java // public class CustomerNotification { // private CustomerNotification() { // // blank to prevent instantiation // } // // private ActionTaken actionTaken; // private String actionTakenAt; // private String actionTakenBy; // private String id; // private Links links; // private Type type; // // /** // * The action that was taken on the notification. Currently this can only be `handled`, which // * means the integrator sent the notification themselves. // * // */ // public ActionTaken getActionTaken() { // return actionTaken; // } // // /** // * Fixed [timestamp](#api-usage-time-zones--dates), recording when this action was taken. // */ // public String getActionTakenAt() { // return actionTakenAt; // } // // /** // * A string identifying the integrator who was able to handle this notification. // */ // public String getActionTakenBy() { // return actionTakenBy; // } // // /** // * The id of the notification. // */ // public String getId() { // return id; // } // // public Links getLinks() { // return links; // } // // /** // * The type of notification the customer shall receive. One of: // * <ul> // * <li>`payment_created`</li> // * <li>`payment_cancelled`</li> // * <li>`mandate_created`</li> // * <li>`mandate_blocked`</li> // * <li>`subscription_created`</li> // * <li>`subscription_cancelled`</li> // * <li>`instalment_schedule_created`</li> // * <li>`instalment_schedule_cancelled`</li> // * </ul> // */ // public Type getType() { // return type; // } // // public enum ActionTaken { // @SerializedName("handled") // HANDLED, @SerializedName("unknown") // UNKNOWN // } // // public enum Type { // @SerializedName("payment_created") // PAYMENT_CREATED, @SerializedName("payment_cancelled") // PAYMENT_CANCELLED, @SerializedName("mandate_created") // MANDATE_CREATED, @SerializedName("mandate_blocked") // MANDATE_BLOCKED, @SerializedName("subscription_created") // SUBSCRIPTION_CREATED, @SerializedName("subscription_cancelled") // SUBSCRIPTION_CANCELLED, @SerializedName("instalment_schedule_created") // INSTALMENT_SCHEDULE_CREATED, @SerializedName("instalment_schedule_cancelled") // INSTALMENT_SCHEDULE_CANCELLED, @SerializedName("unknown") // UNKNOWN // } // // public static class Links { // private Links() { // // blank to prevent instantiation // } // // private String customer; // private String event; // private String mandate; // private String payment; // private String refund; // private String subscription; // // /** // * The customer who should be contacted with this notification. // */ // public String getCustomer() { // return customer; // } // // /** // * The event that triggered the notification to be scheduled. // */ // public String getEvent() { // return event; // } // // /** // * The identifier of the related mandate. // */ // public String getMandate() { // return mandate; // } // // /** // * The identifier of the related payment. // */ // public String getPayment() { // return payment; // } // // /** // * The identifier of the related refund. // */ // public String getRefund() { // return refund; // } // // /** // * The identifier of the related subscription. // */ // public String getSubscription() { // return subscription; // } // } // }
import com.gocardless.http.*; import com.gocardless.resources.CustomerNotification; import com.google.common.collect.ImmutableMap; import java.util.Map;
package com.gocardless.services; /** * Service class for working with customer notification resources. * * Customer Notifications represent the notification which is due to be sent to a customer after an * event has happened. The event, the resource and the customer to be notified are all identified in * the `links` property. * * Note that these are ephemeral records - once the notification has been actioned in some way, it * is no longer visible using this API. * * <p class="restricted-notice"> * <strong>Restricted</strong>: This API is currently only available for approved integrators - * please <a href="mailto:help@gocardless.com">get in touch</a> if you would like to use this API. * </p> */ public class CustomerNotificationService { private final HttpClient httpClient; /** * Constructor. Users of this library should have no need to call this - an instance of this * class can be obtained by calling * {@link com.gocardless.GoCardlessClient#customerNotifications() }. */ public CustomerNotificationService(HttpClient httpClient) { this.httpClient = httpClient; } /** * "Handling" a notification means that you have sent the notification yourself (and don't want * GoCardless to send it). If the notification has already been actioned, or the deadline to * notify has passed, this endpoint will return an `already_actioned` error and you should not * take further action. This endpoint takes no additional parameters. * */ public CustomerNotificationHandleRequest handle(String identity) { return new CustomerNotificationHandleRequest(httpClient, identity); } /** * Request class for {@link CustomerNotificationService#handle }. * * "Handling" a notification means that you have sent the notification yourself (and don't want * GoCardless to send it). If the notification has already been actioned, or the deadline to * notify has passed, this endpoint will return an `already_actioned` error and you should not * take further action. This endpoint takes no additional parameters. * */ public static final class CustomerNotificationHandleRequest
// Path: src/main/java/com/gocardless/resources/CustomerNotification.java // public class CustomerNotification { // private CustomerNotification() { // // blank to prevent instantiation // } // // private ActionTaken actionTaken; // private String actionTakenAt; // private String actionTakenBy; // private String id; // private Links links; // private Type type; // // /** // * The action that was taken on the notification. Currently this can only be `handled`, which // * means the integrator sent the notification themselves. // * // */ // public ActionTaken getActionTaken() { // return actionTaken; // } // // /** // * Fixed [timestamp](#api-usage-time-zones--dates), recording when this action was taken. // */ // public String getActionTakenAt() { // return actionTakenAt; // } // // /** // * A string identifying the integrator who was able to handle this notification. // */ // public String getActionTakenBy() { // return actionTakenBy; // } // // /** // * The id of the notification. // */ // public String getId() { // return id; // } // // public Links getLinks() { // return links; // } // // /** // * The type of notification the customer shall receive. One of: // * <ul> // * <li>`payment_created`</li> // * <li>`payment_cancelled`</li> // * <li>`mandate_created`</li> // * <li>`mandate_blocked`</li> // * <li>`subscription_created`</li> // * <li>`subscription_cancelled`</li> // * <li>`instalment_schedule_created`</li> // * <li>`instalment_schedule_cancelled`</li> // * </ul> // */ // public Type getType() { // return type; // } // // public enum ActionTaken { // @SerializedName("handled") // HANDLED, @SerializedName("unknown") // UNKNOWN // } // // public enum Type { // @SerializedName("payment_created") // PAYMENT_CREATED, @SerializedName("payment_cancelled") // PAYMENT_CANCELLED, @SerializedName("mandate_created") // MANDATE_CREATED, @SerializedName("mandate_blocked") // MANDATE_BLOCKED, @SerializedName("subscription_created") // SUBSCRIPTION_CREATED, @SerializedName("subscription_cancelled") // SUBSCRIPTION_CANCELLED, @SerializedName("instalment_schedule_created") // INSTALMENT_SCHEDULE_CREATED, @SerializedName("instalment_schedule_cancelled") // INSTALMENT_SCHEDULE_CANCELLED, @SerializedName("unknown") // UNKNOWN // } // // public static class Links { // private Links() { // // blank to prevent instantiation // } // // private String customer; // private String event; // private String mandate; // private String payment; // private String refund; // private String subscription; // // /** // * The customer who should be contacted with this notification. // */ // public String getCustomer() { // return customer; // } // // /** // * The event that triggered the notification to be scheduled. // */ // public String getEvent() { // return event; // } // // /** // * The identifier of the related mandate. // */ // public String getMandate() { // return mandate; // } // // /** // * The identifier of the related payment. // */ // public String getPayment() { // return payment; // } // // /** // * The identifier of the related refund. // */ // public String getRefund() { // return refund; // } // // /** // * The identifier of the related subscription. // */ // public String getSubscription() { // return subscription; // } // } // } // Path: src/main/java/com/gocardless/services/CustomerNotificationService.java import com.gocardless.http.*; import com.gocardless.resources.CustomerNotification; import com.google.common.collect.ImmutableMap; import java.util.Map; package com.gocardless.services; /** * Service class for working with customer notification resources. * * Customer Notifications represent the notification which is due to be sent to a customer after an * event has happened. The event, the resource and the customer to be notified are all identified in * the `links` property. * * Note that these are ephemeral records - once the notification has been actioned in some way, it * is no longer visible using this API. * * <p class="restricted-notice"> * <strong>Restricted</strong>: This API is currently only available for approved integrators - * please <a href="mailto:help@gocardless.com">get in touch</a> if you would like to use this API. * </p> */ public class CustomerNotificationService { private final HttpClient httpClient; /** * Constructor. Users of this library should have no need to call this - an instance of this * class can be obtained by calling * {@link com.gocardless.GoCardlessClient#customerNotifications() }. */ public CustomerNotificationService(HttpClient httpClient) { this.httpClient = httpClient; } /** * "Handling" a notification means that you have sent the notification yourself (and don't want * GoCardless to send it). If the notification has already been actioned, or the deadline to * notify has passed, this endpoint will return an `already_actioned` error and you should not * take further action. This endpoint takes no additional parameters. * */ public CustomerNotificationHandleRequest handle(String identity) { return new CustomerNotificationHandleRequest(httpClient, identity); } /** * Request class for {@link CustomerNotificationService#handle }. * * "Handling" a notification means that you have sent the notification yourself (and don't want * GoCardless to send it). If the notification has already been actioned, or the deadline to * notify has passed, this endpoint will return an `already_actioned` error and you should not * take further action. This endpoint takes no additional parameters. * */ public static final class CustomerNotificationHandleRequest
extends PostRequest<CustomerNotification> {
gocardless/gocardless-pro-java
src/main/java/com/gocardless/services/BlockService.java
// Path: src/main/java/com/gocardless/resources/Block.java // public class Block { // private Block() { // // blank to prevent instantiation // } // // private Boolean active; // private BlockType blockType; // private String createdAt; // private String id; // private String reasonDescription; // private ReasonType reasonType; // private String resourceReference; // private String updatedAt; // // /** // * Shows if the block is active or disabled. Only active blocks will be used when deciding if a // * mandate should be blocked. // */ // public Boolean getActive() { // return active; // } // // /** // * Type of entity we will seek to match against when blocking the mandate. This can currently be // * one of 'email', 'email_domain', or 'bank_account'. // */ // public BlockType getBlockType() { // return blockType; // } // // /** // * Fixed [timestamp](#api-usage-time-zones--dates), recording when this resource was created. // */ // public String getCreatedAt() { // return createdAt; // } // // /** // * Unique identifier, beginning with "BLC". // */ // public String getId() { // return id; // } // // /** // * This field is required if the reason_type is other. It should be a description of the reason // * for why you wish to block this payer and why it does not align with the given reason_types. // * This is intended to help us improve our knowledge of types of fraud. // */ // public String getReasonDescription() { // return reasonDescription; // } // // /** // * The reason you wish to block this payer, can currently be one of 'identity_fraud', // * 'no_intent_to_pay', 'unfair_chargeback'. If the reason isn't captured by one of the above // * then 'other' can be selected but you must provide a reason description. // */ // public ReasonType getReasonType() { // return reasonType; // } // // /** // * This field is a reference to the value you wish to block. This may be the raw value (in the // * case of emails or email domains) or the ID of the resource (in the case of bank accounts). // * This means in order to block a specific bank account it must already have been created as a // * resource. // */ // public String getResourceReference() { // return resourceReference; // } // // /** // * Fixed [timestamp](#api-usage-time-zones--dates), recording when this resource was updated. // */ // public String getUpdatedAt() { // return updatedAt; // } // // public enum BlockType { // @SerializedName("email") // EMAIL, @SerializedName("email_domain") // EMAIL_DOMAIN, @SerializedName("bank_account") // BANK_ACCOUNT, @SerializedName("unknown") // UNKNOWN // } // // public enum ReasonType { // @SerializedName("identity_fraud") // IDENTITY_FRAUD, @SerializedName("no_intent_to_pay") // NO_INTENT_TO_PAY, @SerializedName("unfair_chargeback") // UNFAIR_CHARGEBACK, @SerializedName("other") // OTHER, @SerializedName("unknown") // UNKNOWN // } // }
import com.gocardless.http.*; import com.gocardless.resources.Block; import com.google.common.collect.ImmutableMap; import com.google.gson.reflect.TypeToken; import java.util.List; import java.util.Map;
package com.gocardless.services; /** * Service class for working with block resources. * * A block object is a simple rule, when matched, pushes a newly created mandate to a blocked state. * These details can be an exact match, like a bank account or an email, or a more generic match * such as an email domain. New block types may be added over time. Payments and subscriptions can't * be created against mandates in blocked state. * * <p class="notice"> * Client libraries have not yet been updated for this API but will be released soon. This API is * currently only available for approved integrators - please * <a href="mailto:help@gocardless.com">get in touch</a> if you would like to use this API. * </p> */ public class BlockService { private final HttpClient httpClient; /** * Constructor. Users of this library should have no need to call this - an instance of this * class can be obtained by calling {@link com.gocardless.GoCardlessClient#blocks() }. */ public BlockService(HttpClient httpClient) { this.httpClient = httpClient; } /** * Creates a new Block of a given type. By default it will be active. */ public BlockCreateRequest create() { return new BlockCreateRequest(httpClient); } /** * Retrieves the details of an existing block. */ public BlockGetRequest get(String identity) { return new BlockGetRequest(httpClient, identity); } /** * Returns a [cursor-paginated](#api-usage-cursor-pagination) list of your blocks. */
// Path: src/main/java/com/gocardless/resources/Block.java // public class Block { // private Block() { // // blank to prevent instantiation // } // // private Boolean active; // private BlockType blockType; // private String createdAt; // private String id; // private String reasonDescription; // private ReasonType reasonType; // private String resourceReference; // private String updatedAt; // // /** // * Shows if the block is active or disabled. Only active blocks will be used when deciding if a // * mandate should be blocked. // */ // public Boolean getActive() { // return active; // } // // /** // * Type of entity we will seek to match against when blocking the mandate. This can currently be // * one of 'email', 'email_domain', or 'bank_account'. // */ // public BlockType getBlockType() { // return blockType; // } // // /** // * Fixed [timestamp](#api-usage-time-zones--dates), recording when this resource was created. // */ // public String getCreatedAt() { // return createdAt; // } // // /** // * Unique identifier, beginning with "BLC". // */ // public String getId() { // return id; // } // // /** // * This field is required if the reason_type is other. It should be a description of the reason // * for why you wish to block this payer and why it does not align with the given reason_types. // * This is intended to help us improve our knowledge of types of fraud. // */ // public String getReasonDescription() { // return reasonDescription; // } // // /** // * The reason you wish to block this payer, can currently be one of 'identity_fraud', // * 'no_intent_to_pay', 'unfair_chargeback'. If the reason isn't captured by one of the above // * then 'other' can be selected but you must provide a reason description. // */ // public ReasonType getReasonType() { // return reasonType; // } // // /** // * This field is a reference to the value you wish to block. This may be the raw value (in the // * case of emails or email domains) or the ID of the resource (in the case of bank accounts). // * This means in order to block a specific bank account it must already have been created as a // * resource. // */ // public String getResourceReference() { // return resourceReference; // } // // /** // * Fixed [timestamp](#api-usage-time-zones--dates), recording when this resource was updated. // */ // public String getUpdatedAt() { // return updatedAt; // } // // public enum BlockType { // @SerializedName("email") // EMAIL, @SerializedName("email_domain") // EMAIL_DOMAIN, @SerializedName("bank_account") // BANK_ACCOUNT, @SerializedName("unknown") // UNKNOWN // } // // public enum ReasonType { // @SerializedName("identity_fraud") // IDENTITY_FRAUD, @SerializedName("no_intent_to_pay") // NO_INTENT_TO_PAY, @SerializedName("unfair_chargeback") // UNFAIR_CHARGEBACK, @SerializedName("other") // OTHER, @SerializedName("unknown") // UNKNOWN // } // } // Path: src/main/java/com/gocardless/services/BlockService.java import com.gocardless.http.*; import com.gocardless.resources.Block; import com.google.common.collect.ImmutableMap; import com.google.gson.reflect.TypeToken; import java.util.List; import java.util.Map; package com.gocardless.services; /** * Service class for working with block resources. * * A block object is a simple rule, when matched, pushes a newly created mandate to a blocked state. * These details can be an exact match, like a bank account or an email, or a more generic match * such as an email domain. New block types may be added over time. Payments and subscriptions can't * be created against mandates in blocked state. * * <p class="notice"> * Client libraries have not yet been updated for this API but will be released soon. This API is * currently only available for approved integrators - please * <a href="mailto:help@gocardless.com">get in touch</a> if you would like to use this API. * </p> */ public class BlockService { private final HttpClient httpClient; /** * Constructor. Users of this library should have no need to call this - an instance of this * class can be obtained by calling {@link com.gocardless.GoCardlessClient#blocks() }. */ public BlockService(HttpClient httpClient) { this.httpClient = httpClient; } /** * Creates a new Block of a given type. By default it will be active. */ public BlockCreateRequest create() { return new BlockCreateRequest(httpClient); } /** * Retrieves the details of an existing block. */ public BlockGetRequest get(String identity) { return new BlockGetRequest(httpClient, identity); } /** * Returns a [cursor-paginated](#api-usage-cursor-pagination) list of your blocks. */
public BlockListRequest<ListResponse<Block>> list() {
diribet/aqdef-tools
src/main/java/cz/diribet/aqdef/convert/custom/K0006ValueConverter.java
// Path: src/main/java/cz/diribet/aqdef/convert/IKKeyValueConverter.java // public interface IKKeyValueConverter<T> { // // public T convert(String value) throws KKeyValueConversionException; // // public String toString(T value); // // } // // Path: src/main/java/cz/diribet/aqdef/convert/KKeyValueConversionException.java // public class KKeyValueConversionException extends Exception { // // public KKeyValueConversionException(String value, Class<?> dataType, Throwable cause) { // super("Failed to convert value: " + value + " to data type: " + dataType.getName(), cause); // } // // public KKeyValueConversionException(String message, Throwable cause) { // super(message, cause); // } // // public KKeyValueConversionException(String message) { // super(message); // } // // }
import org.apache.commons.lang3.StringUtils; import cz.diribet.aqdef.convert.IKKeyValueConverter; import cz.diribet.aqdef.convert.KKeyValueConversionException;
package cz.diribet.aqdef.convert.custom; /** * Removes leading # from K0006 (charge). * * @author Vlastimil Dolejs * */ public class K0006ValueConverter implements IKKeyValueConverter<String> { @Override
// Path: src/main/java/cz/diribet/aqdef/convert/IKKeyValueConverter.java // public interface IKKeyValueConverter<T> { // // public T convert(String value) throws KKeyValueConversionException; // // public String toString(T value); // // } // // Path: src/main/java/cz/diribet/aqdef/convert/KKeyValueConversionException.java // public class KKeyValueConversionException extends Exception { // // public KKeyValueConversionException(String value, Class<?> dataType, Throwable cause) { // super("Failed to convert value: " + value + " to data type: " + dataType.getName(), cause); // } // // public KKeyValueConversionException(String message, Throwable cause) { // super(message, cause); // } // // public KKeyValueConversionException(String message) { // super(message); // } // // } // Path: src/main/java/cz/diribet/aqdef/convert/custom/K0006ValueConverter.java import org.apache.commons.lang3.StringUtils; import cz.diribet.aqdef.convert.IKKeyValueConverter; import cz.diribet.aqdef.convert.KKeyValueConversionException; package cz.diribet.aqdef.convert.custom; /** * Removes leading # from K0006 (charge). * * @author Vlastimil Dolejs * */ public class K0006ValueConverter implements IKKeyValueConverter<String> { @Override
public String convert(String value) throws KKeyValueConversionException {
diribet/aqdef-tools
src/main/java/cz/diribet/aqdef/convert/custom/K0020ValueConverter.java
// Path: src/main/java/cz/diribet/aqdef/convert/IKKeyValueConverter.java // public interface IKKeyValueConverter<T> { // // public T convert(String value) throws KKeyValueConversionException; // // public String toString(T value); // // } // // Path: src/main/java/cz/diribet/aqdef/convert/IntegerKKeyValueConverter.java // public class IntegerKKeyValueConverter implements IKKeyValueConverter<Integer> { // // @Override // public Integer convert(String value) throws KKeyValueConversionException { // if (StringUtils.isEmpty(value)) { // return null; // } // // try { // return Integer.valueOf(value); // } catch (Throwable e) { // throw new KKeyValueConversionException(value, Integer.class, e); // } // } // // @Override // public String toString(Integer value) { // if (value == null) { // return null; // } else { // return value.toString(); // } // } // // } // // Path: src/main/java/cz/diribet/aqdef/convert/KKeyValueConversionException.java // public class KKeyValueConversionException extends Exception { // // public KKeyValueConversionException(String value, Class<?> dataType, Throwable cause) { // super("Failed to convert value: " + value + " to data type: " + dataType.getName(), cause); // } // // public KKeyValueConversionException(String message, Throwable cause) { // super(message, cause); // } // // public KKeyValueConversionException(String message) { // super(message); // } // // }
import cz.diribet.aqdef.convert.IKKeyValueConverter; import cz.diribet.aqdef.convert.IntegerKKeyValueConverter; import cz.diribet.aqdef.convert.KKeyValueConversionException;
package cz.diribet.aqdef.convert.custom; /** * Divides value of K0020 by 1000. * * @author Vlastimil Dolejs * */ public class K0020ValueConverter implements IKKeyValueConverter<Integer> { private IntegerKKeyValueConverter integerConverter = new IntegerKKeyValueConverter(); @Override
// Path: src/main/java/cz/diribet/aqdef/convert/IKKeyValueConverter.java // public interface IKKeyValueConverter<T> { // // public T convert(String value) throws KKeyValueConversionException; // // public String toString(T value); // // } // // Path: src/main/java/cz/diribet/aqdef/convert/IntegerKKeyValueConverter.java // public class IntegerKKeyValueConverter implements IKKeyValueConverter<Integer> { // // @Override // public Integer convert(String value) throws KKeyValueConversionException { // if (StringUtils.isEmpty(value)) { // return null; // } // // try { // return Integer.valueOf(value); // } catch (Throwable e) { // throw new KKeyValueConversionException(value, Integer.class, e); // } // } // // @Override // public String toString(Integer value) { // if (value == null) { // return null; // } else { // return value.toString(); // } // } // // } // // Path: src/main/java/cz/diribet/aqdef/convert/KKeyValueConversionException.java // public class KKeyValueConversionException extends Exception { // // public KKeyValueConversionException(String value, Class<?> dataType, Throwable cause) { // super("Failed to convert value: " + value + " to data type: " + dataType.getName(), cause); // } // // public KKeyValueConversionException(String message, Throwable cause) { // super(message, cause); // } // // public KKeyValueConversionException(String message) { // super(message); // } // // } // Path: src/main/java/cz/diribet/aqdef/convert/custom/K0020ValueConverter.java import cz.diribet.aqdef.convert.IKKeyValueConverter; import cz.diribet.aqdef.convert.IntegerKKeyValueConverter; import cz.diribet.aqdef.convert.KKeyValueConversionException; package cz.diribet.aqdef.convert.custom; /** * Divides value of K0020 by 1000. * * @author Vlastimil Dolejs * */ public class K0020ValueConverter implements IKKeyValueConverter<Integer> { private IntegerKKeyValueConverter integerConverter = new IntegerKKeyValueConverter(); @Override
public Integer convert(String value) throws KKeyValueConversionException {
diribet/aqdef-tools
src/main/java/cz/diribet/aqdef/convert/custom/K0005ValueConverter.java
// Path: src/main/java/cz/diribet/aqdef/convert/IKKeyValueConverter.java // public interface IKKeyValueConverter<T> { // // public T convert(String value) throws KKeyValueConversionException; // // public String toString(T value); // // } // // Path: src/main/java/cz/diribet/aqdef/convert/KKeyValueConversionException.java // public class KKeyValueConversionException extends Exception { // // public KKeyValueConversionException(String value, Class<?> dataType, Throwable cause) { // super("Failed to convert value: " + value + " to data type: " + dataType.getName(), cause); // } // // public KKeyValueConversionException(String message, Throwable cause) { // super(message, cause); // } // // public KKeyValueConversionException(String message) { // super(message); // } // // }
import static java.util.stream.Collectors.joining; import java.util.List; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import com.google.common.collect.Lists; import cz.diribet.aqdef.convert.IKKeyValueConverter; import cz.diribet.aqdef.convert.KKeyValueConversionException;
package cz.diribet.aqdef.convert.custom; /** * Transform K0005 to list of event ids. <br> * Sample content of K0005: "100, 101, 150" * * @author Vlastimil Dolejs * */ public class K0005ValueConverter implements IKKeyValueConverter<List<Integer>> { @Override
// Path: src/main/java/cz/diribet/aqdef/convert/IKKeyValueConverter.java // public interface IKKeyValueConverter<T> { // // public T convert(String value) throws KKeyValueConversionException; // // public String toString(T value); // // } // // Path: src/main/java/cz/diribet/aqdef/convert/KKeyValueConversionException.java // public class KKeyValueConversionException extends Exception { // // public KKeyValueConversionException(String value, Class<?> dataType, Throwable cause) { // super("Failed to convert value: " + value + " to data type: " + dataType.getName(), cause); // } // // public KKeyValueConversionException(String message, Throwable cause) { // super(message, cause); // } // // public KKeyValueConversionException(String message) { // super(message); // } // // } // Path: src/main/java/cz/diribet/aqdef/convert/custom/K0005ValueConverter.java import static java.util.stream.Collectors.joining; import java.util.List; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import com.google.common.collect.Lists; import cz.diribet.aqdef.convert.IKKeyValueConverter; import cz.diribet.aqdef.convert.KKeyValueConversionException; package cz.diribet.aqdef.convert.custom; /** * Transform K0005 to list of event ids. <br> * Sample content of K0005: "100, 101, 150" * * @author Vlastimil Dolejs * */ public class K0005ValueConverter implements IKKeyValueConverter<List<Integer>> { @Override
public List<Integer> convert(String value) throws KKeyValueConversionException {
lingochamp/FileDownloader
library/src/main/java/com/liulishuo/filedownloader/FileDownloadMessageStation.java
// Path: library/src/main/java/com/liulishuo/filedownloader/util/FileDownloadExecutors.java // public class FileDownloadExecutors { // private static final int DEFAULT_IDLE_SECOND = 15; // // public static ThreadPoolExecutor newFixedThreadPool(String prefix) { // return new ThreadPoolExecutor(0, Integer.MAX_VALUE, // DEFAULT_IDLE_SECOND, TimeUnit.SECONDS, // new SynchronousQueue<Runnable>(), new FileDownloadThreadFactory(prefix)); // } // // public static ThreadPoolExecutor newDefaultThreadPool(int nThreads, String prefix) { // return newDefaultThreadPool(nThreads, new LinkedBlockingQueue<Runnable>(), prefix); // } // // public static ThreadPoolExecutor newDefaultThreadPool(int nThreads, // LinkedBlockingQueue<Runnable> queue, // String prefix) { // final ThreadPoolExecutor executor = new ThreadPoolExecutor(nThreads, nThreads, // DEFAULT_IDLE_SECOND, TimeUnit.SECONDS, queue, // new FileDownloadThreadFactory(prefix)); // executor.allowCoreThreadTimeOut(true); // return executor; // } // // static class FileDownloadThreadFactory implements ThreadFactory { // private static final AtomicInteger POOL_NUMBER = new AtomicInteger(1); // private final String namePrefix; // private final ThreadGroup group; // private final AtomicInteger threadNumber = new AtomicInteger(1); // // FileDownloadThreadFactory(String prefix) { // group = Thread.currentThread().getThreadGroup(); // namePrefix = FileDownloadUtils.getThreadPoolName(prefix); // } // // @Override // public Thread newThread(Runnable r) { // Thread t = new Thread(group, r, namePrefix + threadNumber.getAndIncrement(), 0); // // if (t.isDaemon()) t.setDaemon(false); // if (t.getPriority() != Thread.NORM_PRIORITY) t.setPriority(Thread.NORM_PRIORITY); // return t; // } // } // // }
import android.os.Handler; import android.os.Looper; import android.os.Message; import com.liulishuo.filedownloader.util.FileDownloadExecutors; import java.util.ArrayList; import java.util.concurrent.Executor; import java.util.concurrent.LinkedBlockingQueue;
/* * Copyright (c) 2015 LingoChamp Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.liulishuo.filedownloader; /** * The message station to transfer task events to {@link FileDownloadListener}. */ @SuppressWarnings("WeakerAccess") public class FileDownloadMessageStation {
// Path: library/src/main/java/com/liulishuo/filedownloader/util/FileDownloadExecutors.java // public class FileDownloadExecutors { // private static final int DEFAULT_IDLE_SECOND = 15; // // public static ThreadPoolExecutor newFixedThreadPool(String prefix) { // return new ThreadPoolExecutor(0, Integer.MAX_VALUE, // DEFAULT_IDLE_SECOND, TimeUnit.SECONDS, // new SynchronousQueue<Runnable>(), new FileDownloadThreadFactory(prefix)); // } // // public static ThreadPoolExecutor newDefaultThreadPool(int nThreads, String prefix) { // return newDefaultThreadPool(nThreads, new LinkedBlockingQueue<Runnable>(), prefix); // } // // public static ThreadPoolExecutor newDefaultThreadPool(int nThreads, // LinkedBlockingQueue<Runnable> queue, // String prefix) { // final ThreadPoolExecutor executor = new ThreadPoolExecutor(nThreads, nThreads, // DEFAULT_IDLE_SECOND, TimeUnit.SECONDS, queue, // new FileDownloadThreadFactory(prefix)); // executor.allowCoreThreadTimeOut(true); // return executor; // } // // static class FileDownloadThreadFactory implements ThreadFactory { // private static final AtomicInteger POOL_NUMBER = new AtomicInteger(1); // private final String namePrefix; // private final ThreadGroup group; // private final AtomicInteger threadNumber = new AtomicInteger(1); // // FileDownloadThreadFactory(String prefix) { // group = Thread.currentThread().getThreadGroup(); // namePrefix = FileDownloadUtils.getThreadPoolName(prefix); // } // // @Override // public Thread newThread(Runnable r) { // Thread t = new Thread(group, r, namePrefix + threadNumber.getAndIncrement(), 0); // // if (t.isDaemon()) t.setDaemon(false); // if (t.getPriority() != Thread.NORM_PRIORITY) t.setPriority(Thread.NORM_PRIORITY); // return t; // } // } // // } // Path: library/src/main/java/com/liulishuo/filedownloader/FileDownloadMessageStation.java import android.os.Handler; import android.os.Looper; import android.os.Message; import com.liulishuo.filedownloader.util.FileDownloadExecutors; import java.util.ArrayList; import java.util.concurrent.Executor; import java.util.concurrent.LinkedBlockingQueue; /* * Copyright (c) 2015 LingoChamp Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.liulishuo.filedownloader; /** * The message station to transfer task events to {@link FileDownloadListener}. */ @SuppressWarnings("WeakerAccess") public class FileDownloadMessageStation {
private static final Executor BLOCK_COMPLETED_POOL = FileDownloadExecutors.
lingochamp/FileDownloader
library/src/main/java/com/liulishuo/filedownloader/FileDownloadConnectListener.java
// Path: library/src/main/java/com/liulishuo/filedownloader/event/DownloadServiceConnectChangedEvent.java // public class DownloadServiceConnectChangedEvent extends IDownloadEvent { // public static final String ID = "event.service.connect.changed"; // // public DownloadServiceConnectChangedEvent(final ConnectStatus status, // final Class<?> serviceClass) { // super(ID); // // this.status = status; // this.serviceClass = serviceClass; // } // // private final ConnectStatus status; // // public enum ConnectStatus { // connected, disconnected, // // the process hosting the service has crashed or been killed. (do not be unbound manually) // lost // } // // public ConnectStatus getStatus() { // return status; // } // // private final Class<?> serviceClass; // // public boolean isSuchService(final Class<?> serviceClass) { // return this.serviceClass != null // && this.serviceClass.getName().equals(serviceClass.getName()); // // } // } // // Path: library/src/main/java/com/liulishuo/filedownloader/event/IDownloadEvent.java // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // public abstract class IDownloadEvent { // public Runnable callback = null; // // public IDownloadEvent(final String id) { // this.id = id; // } // // /** // * @see #IDownloadEvent(String) // * @deprecated do not handle ORDER any more. // */ // public IDownloadEvent(final String id, boolean order) { // this.id = id; // if (order) { // FileDownloadLog.w(this, "do not handle ORDER any more, %s", id); // } // } // // @SuppressWarnings("WeakerAccess") // protected final String id; // // public final String getId() { // return this.id; // } // } // // Path: library/src/main/java/com/liulishuo/filedownloader/event/IDownloadListener.java // public abstract class IDownloadListener { // // // private final int priority; // // // public IDownloadListener(int priority) { // // this.priority = priority; // // } // // // public int getPriority() { // // return this.priority; // // } // // public abstract boolean callback(IDownloadEvent event); // // }
import com.liulishuo.filedownloader.event.DownloadServiceConnectChangedEvent; import com.liulishuo.filedownloader.event.IDownloadEvent; import com.liulishuo.filedownloader.event.IDownloadListener;
/* * Copyright (c) 2015 LingoChamp Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.liulishuo.filedownloader; /** * The listener for listening whether the service establishes connection or disconnected. * * @see com.liulishuo.filedownloader.services.BaseFileServiceUIGuard#releaseConnect(boolean) */ public abstract class FileDownloadConnectListener extends IDownloadListener { private DownloadServiceConnectChangedEvent.ConnectStatus mConnectStatus; public FileDownloadConnectListener() { } @Override
// Path: library/src/main/java/com/liulishuo/filedownloader/event/DownloadServiceConnectChangedEvent.java // public class DownloadServiceConnectChangedEvent extends IDownloadEvent { // public static final String ID = "event.service.connect.changed"; // // public DownloadServiceConnectChangedEvent(final ConnectStatus status, // final Class<?> serviceClass) { // super(ID); // // this.status = status; // this.serviceClass = serviceClass; // } // // private final ConnectStatus status; // // public enum ConnectStatus { // connected, disconnected, // // the process hosting the service has crashed or been killed. (do not be unbound manually) // lost // } // // public ConnectStatus getStatus() { // return status; // } // // private final Class<?> serviceClass; // // public boolean isSuchService(final Class<?> serviceClass) { // return this.serviceClass != null // && this.serviceClass.getName().equals(serviceClass.getName()); // // } // } // // Path: library/src/main/java/com/liulishuo/filedownloader/event/IDownloadEvent.java // @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) // public abstract class IDownloadEvent { // public Runnable callback = null; // // public IDownloadEvent(final String id) { // this.id = id; // } // // /** // * @see #IDownloadEvent(String) // * @deprecated do not handle ORDER any more. // */ // public IDownloadEvent(final String id, boolean order) { // this.id = id; // if (order) { // FileDownloadLog.w(this, "do not handle ORDER any more, %s", id); // } // } // // @SuppressWarnings("WeakerAccess") // protected final String id; // // public final String getId() { // return this.id; // } // } // // Path: library/src/main/java/com/liulishuo/filedownloader/event/IDownloadListener.java // public abstract class IDownloadListener { // // // private final int priority; // // // public IDownloadListener(int priority) { // // this.priority = priority; // // } // // // public int getPriority() { // // return this.priority; // // } // // public abstract boolean callback(IDownloadEvent event); // // } // Path: library/src/main/java/com/liulishuo/filedownloader/FileDownloadConnectListener.java import com.liulishuo.filedownloader.event.DownloadServiceConnectChangedEvent; import com.liulishuo.filedownloader.event.IDownloadEvent; import com.liulishuo.filedownloader.event.IDownloadListener; /* * Copyright (c) 2015 LingoChamp Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.liulishuo.filedownloader; /** * The listener for listening whether the service establishes connection or disconnected. * * @see com.liulishuo.filedownloader.services.BaseFileServiceUIGuard#releaseConnect(boolean) */ public abstract class FileDownloadConnectListener extends IDownloadListener { private DownloadServiceConnectChangedEvent.ConnectStatus mConnectStatus; public FileDownloadConnectListener() { } @Override
public boolean callback(IDownloadEvent event) {
lingochamp/FileDownloader
library/src/main/java/com/liulishuo/filedownloader/event/DownloadEventPoolImpl.java
// Path: library/src/main/java/com/liulishuo/filedownloader/util/FileDownloadExecutors.java // public class FileDownloadExecutors { // private static final int DEFAULT_IDLE_SECOND = 15; // // public static ThreadPoolExecutor newFixedThreadPool(String prefix) { // return new ThreadPoolExecutor(0, Integer.MAX_VALUE, // DEFAULT_IDLE_SECOND, TimeUnit.SECONDS, // new SynchronousQueue<Runnable>(), new FileDownloadThreadFactory(prefix)); // } // // public static ThreadPoolExecutor newDefaultThreadPool(int nThreads, String prefix) { // return newDefaultThreadPool(nThreads, new LinkedBlockingQueue<Runnable>(), prefix); // } // // public static ThreadPoolExecutor newDefaultThreadPool(int nThreads, // LinkedBlockingQueue<Runnable> queue, // String prefix) { // final ThreadPoolExecutor executor = new ThreadPoolExecutor(nThreads, nThreads, // DEFAULT_IDLE_SECOND, TimeUnit.SECONDS, queue, // new FileDownloadThreadFactory(prefix)); // executor.allowCoreThreadTimeOut(true); // return executor; // } // // static class FileDownloadThreadFactory implements ThreadFactory { // private static final AtomicInteger POOL_NUMBER = new AtomicInteger(1); // private final String namePrefix; // private final ThreadGroup group; // private final AtomicInteger threadNumber = new AtomicInteger(1); // // FileDownloadThreadFactory(String prefix) { // group = Thread.currentThread().getThreadGroup(); // namePrefix = FileDownloadUtils.getThreadPoolName(prefix); // } // // @Override // public Thread newThread(Runnable r) { // Thread t = new Thread(group, r, namePrefix + threadNumber.getAndIncrement(), 0); // // if (t.isDaemon()) t.setDaemon(false); // if (t.getPriority() != Thread.NORM_PRIORITY) t.setPriority(Thread.NORM_PRIORITY); // return t; // } // } // // } // // Path: library/src/main/java/com/liulishuo/filedownloader/util/FileDownloadLog.java // public class FileDownloadLog { // // public static boolean NEED_LOG = false; // // private static final String TAG = "FileDownloader."; // // public static void e(Object o, Throwable e, String msg, Object... args) { // log(Log.ERROR, o, e, msg, args); // } // // public static void e(Object o, String msg, Object... args) { // log(Log.ERROR, o, msg, args); // } // // public static void i(Object o, String msg, Object... args) { // log(Log.INFO, o, msg, args); // } // // public static void d(Object o, String msg, Object... args) { // log(Log.DEBUG, o, msg, args); // } // // public static void w(Object o, String msg, Object... args) { // log(Log.WARN, o, msg, args); // } // // public static void v(Object o, String msg, Object... args) { // log(Log.VERBOSE, o, msg, args); // } // // private static void log(int priority, Object o, String message, Object... args) { // log(priority, o, null, message, args); // } // // private static void log(int priority, Object o, Throwable throwable, String message, // Object... args) { // final boolean force = priority >= Log.WARN; // if (!force && !NEED_LOG) { // return; // } // // Log.println(priority, getTag(o), FileDownloadUtils.formatString(message, args)); // if (throwable != null) { // throwable.printStackTrace(); // } // } // // private static String getTag(final Object o) { // return TAG + ((o instanceof Class) // ? ((Class) o).getSimpleName() : o.getClass().getSimpleName()); // } // }
import com.liulishuo.filedownloader.util.FileDownloadExecutors; import com.liulishuo.filedownloader.util.FileDownloadLog; import java.util.HashMap; import java.util.LinkedList; import java.util.concurrent.Executor;
/* * Copyright (c) 2015 LingoChamp Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.liulishuo.filedownloader.event; /** * Implementing actions for event pool. */ public class DownloadEventPoolImpl implements IDownloadEventPool { private final Executor threadPool = FileDownloadExecutors.newDefaultThreadPool(10, "EventPool"); private final HashMap<String, LinkedList<IDownloadListener>> listenersMap = new HashMap<>(); @Override public boolean addListener(final String eventId, final IDownloadListener listener) {
// Path: library/src/main/java/com/liulishuo/filedownloader/util/FileDownloadExecutors.java // public class FileDownloadExecutors { // private static final int DEFAULT_IDLE_SECOND = 15; // // public static ThreadPoolExecutor newFixedThreadPool(String prefix) { // return new ThreadPoolExecutor(0, Integer.MAX_VALUE, // DEFAULT_IDLE_SECOND, TimeUnit.SECONDS, // new SynchronousQueue<Runnable>(), new FileDownloadThreadFactory(prefix)); // } // // public static ThreadPoolExecutor newDefaultThreadPool(int nThreads, String prefix) { // return newDefaultThreadPool(nThreads, new LinkedBlockingQueue<Runnable>(), prefix); // } // // public static ThreadPoolExecutor newDefaultThreadPool(int nThreads, // LinkedBlockingQueue<Runnable> queue, // String prefix) { // final ThreadPoolExecutor executor = new ThreadPoolExecutor(nThreads, nThreads, // DEFAULT_IDLE_SECOND, TimeUnit.SECONDS, queue, // new FileDownloadThreadFactory(prefix)); // executor.allowCoreThreadTimeOut(true); // return executor; // } // // static class FileDownloadThreadFactory implements ThreadFactory { // private static final AtomicInteger POOL_NUMBER = new AtomicInteger(1); // private final String namePrefix; // private final ThreadGroup group; // private final AtomicInteger threadNumber = new AtomicInteger(1); // // FileDownloadThreadFactory(String prefix) { // group = Thread.currentThread().getThreadGroup(); // namePrefix = FileDownloadUtils.getThreadPoolName(prefix); // } // // @Override // public Thread newThread(Runnable r) { // Thread t = new Thread(group, r, namePrefix + threadNumber.getAndIncrement(), 0); // // if (t.isDaemon()) t.setDaemon(false); // if (t.getPriority() != Thread.NORM_PRIORITY) t.setPriority(Thread.NORM_PRIORITY); // return t; // } // } // // } // // Path: library/src/main/java/com/liulishuo/filedownloader/util/FileDownloadLog.java // public class FileDownloadLog { // // public static boolean NEED_LOG = false; // // private static final String TAG = "FileDownloader."; // // public static void e(Object o, Throwable e, String msg, Object... args) { // log(Log.ERROR, o, e, msg, args); // } // // public static void e(Object o, String msg, Object... args) { // log(Log.ERROR, o, msg, args); // } // // public static void i(Object o, String msg, Object... args) { // log(Log.INFO, o, msg, args); // } // // public static void d(Object o, String msg, Object... args) { // log(Log.DEBUG, o, msg, args); // } // // public static void w(Object o, String msg, Object... args) { // log(Log.WARN, o, msg, args); // } // // public static void v(Object o, String msg, Object... args) { // log(Log.VERBOSE, o, msg, args); // } // // private static void log(int priority, Object o, String message, Object... args) { // log(priority, o, null, message, args); // } // // private static void log(int priority, Object o, Throwable throwable, String message, // Object... args) { // final boolean force = priority >= Log.WARN; // if (!force && !NEED_LOG) { // return; // } // // Log.println(priority, getTag(o), FileDownloadUtils.formatString(message, args)); // if (throwable != null) { // throwable.printStackTrace(); // } // } // // private static String getTag(final Object o) { // return TAG + ((o instanceof Class) // ? ((Class) o).getSimpleName() : o.getClass().getSimpleName()); // } // } // Path: library/src/main/java/com/liulishuo/filedownloader/event/DownloadEventPoolImpl.java import com.liulishuo.filedownloader.util.FileDownloadExecutors; import com.liulishuo.filedownloader.util.FileDownloadLog; import java.util.HashMap; import java.util.LinkedList; import java.util.concurrent.Executor; /* * Copyright (c) 2015 LingoChamp Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.liulishuo.filedownloader.event; /** * Implementing actions for event pool. */ public class DownloadEventPoolImpl implements IDownloadEventPool { private final Executor threadPool = FileDownloadExecutors.newDefaultThreadPool(10, "EventPool"); private final HashMap<String, LinkedList<IDownloadListener>> listenersMap = new HashMap<>(); @Override public boolean addListener(final String eventId, final IDownloadListener listener) {
if (FileDownloadLog.NEED_LOG) {
lingochamp/FileDownloader
library/src/main/java/com/liulishuo/filedownloader/IFileDownloadServiceProxy.java
// Path: library/src/main/java/com/liulishuo/filedownloader/model/FileDownloadHeader.java // public class FileDownloadHeader implements Parcelable { // // private HashMap<String, List<String>> mHeaderMap; // // /** // * We have already handled etag, and will add 'If-Match' & 'Range' value if it works. // * // * @see com.liulishuo.filedownloader.download.ConnectTask#addUserRequiredHeader // */ // public void add(String name, String value) { // if (name == null) throw new NullPointerException("name == null"); // if (name.isEmpty()) throw new IllegalArgumentException("name is empty"); // if (value == null) throw new NullPointerException("value == null"); // // if (mHeaderMap == null) { // mHeaderMap = new HashMap<>(); // } // // List<String> values = mHeaderMap.get(name); // if (values == null) { // values = new ArrayList<>(); // mHeaderMap.put(name, values); // } // // if (!values.contains(value)) { // values.add(value); // } // } // // /** // * We have already handled etag, and will add 'If-Match' & 'Range' value if it works. // * // * @see com.liulishuo.filedownloader.download.ConnectTask#addUserRequiredHeader // */ // public void add(String line) { // String[] parsed = line.split(":"); // final String name = parsed[0].trim(); // final String value = parsed[1].trim(); // // add(name, value); // } // // /** // * Remove all files with the name. // */ // public void removeAll(String name) { // if (mHeaderMap == null) { // return; // } // // mHeaderMap.remove(name); // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeMap(mHeaderMap); // } // // public HashMap<String, List<String>> getHeaders() { // return mHeaderMap; // } // // public FileDownloadHeader() { // } // // protected FileDownloadHeader(Parcel in) { // //noinspection unchecked // this.mHeaderMap = in.readHashMap(String.class.getClassLoader()); // } // // public static final Creator<FileDownloadHeader> CREATOR = new Creator<FileDownloadHeader>() { // public FileDownloadHeader createFromParcel(Parcel source) { // return new FileDownloadHeader(source); // } // // public FileDownloadHeader[] newArray(int size) { // return new FileDownloadHeader[size]; // } // }; // // @Override // public String toString() { // return mHeaderMap.toString(); // } // }
import android.app.Notification; import android.content.Context; import com.liulishuo.filedownloader.model.FileDownloadHeader;
/* * Copyright (c) 2015 LingoChamp Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.liulishuo.filedownloader; /** * The interface to access the FileDownloadService. */ public interface IFileDownloadServiceProxy { boolean start(final String url, final String path, final boolean pathAsDirectory, final int callbackProgressTimes, final int callbackProgressMinIntervalMillis, final int autoRetryTimes, boolean forceReDownload,
// Path: library/src/main/java/com/liulishuo/filedownloader/model/FileDownloadHeader.java // public class FileDownloadHeader implements Parcelable { // // private HashMap<String, List<String>> mHeaderMap; // // /** // * We have already handled etag, and will add 'If-Match' & 'Range' value if it works. // * // * @see com.liulishuo.filedownloader.download.ConnectTask#addUserRequiredHeader // */ // public void add(String name, String value) { // if (name == null) throw new NullPointerException("name == null"); // if (name.isEmpty()) throw new IllegalArgumentException("name is empty"); // if (value == null) throw new NullPointerException("value == null"); // // if (mHeaderMap == null) { // mHeaderMap = new HashMap<>(); // } // // List<String> values = mHeaderMap.get(name); // if (values == null) { // values = new ArrayList<>(); // mHeaderMap.put(name, values); // } // // if (!values.contains(value)) { // values.add(value); // } // } // // /** // * We have already handled etag, and will add 'If-Match' & 'Range' value if it works. // * // * @see com.liulishuo.filedownloader.download.ConnectTask#addUserRequiredHeader // */ // public void add(String line) { // String[] parsed = line.split(":"); // final String name = parsed[0].trim(); // final String value = parsed[1].trim(); // // add(name, value); // } // // /** // * Remove all files with the name. // */ // public void removeAll(String name) { // if (mHeaderMap == null) { // return; // } // // mHeaderMap.remove(name); // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeMap(mHeaderMap); // } // // public HashMap<String, List<String>> getHeaders() { // return mHeaderMap; // } // // public FileDownloadHeader() { // } // // protected FileDownloadHeader(Parcel in) { // //noinspection unchecked // this.mHeaderMap = in.readHashMap(String.class.getClassLoader()); // } // // public static final Creator<FileDownloadHeader> CREATOR = new Creator<FileDownloadHeader>() { // public FileDownloadHeader createFromParcel(Parcel source) { // return new FileDownloadHeader(source); // } // // public FileDownloadHeader[] newArray(int size) { // return new FileDownloadHeader[size]; // } // }; // // @Override // public String toString() { // return mHeaderMap.toString(); // } // } // Path: library/src/main/java/com/liulishuo/filedownloader/IFileDownloadServiceProxy.java import android.app.Notification; import android.content.Context; import com.liulishuo.filedownloader.model.FileDownloadHeader; /* * Copyright (c) 2015 LingoChamp Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.liulishuo.filedownloader; /** * The interface to access the FileDownloadService. */ public interface IFileDownloadServiceProxy { boolean start(final String url, final String path, final boolean pathAsDirectory, final int callbackProgressTimes, final int callbackProgressMinIntervalMillis, final int autoRetryTimes, boolean forceReDownload,
final FileDownloadHeader header, boolean isWifiRequired);
lingochamp/FileDownloader
library/src/main/java/com/liulishuo/filedownloader/event/IDownloadEvent.java
// Path: library/src/main/java/com/liulishuo/filedownloader/util/FileDownloadLog.java // public class FileDownloadLog { // // public static boolean NEED_LOG = false; // // private static final String TAG = "FileDownloader."; // // public static void e(Object o, Throwable e, String msg, Object... args) { // log(Log.ERROR, o, e, msg, args); // } // // public static void e(Object o, String msg, Object... args) { // log(Log.ERROR, o, msg, args); // } // // public static void i(Object o, String msg, Object... args) { // log(Log.INFO, o, msg, args); // } // // public static void d(Object o, String msg, Object... args) { // log(Log.DEBUG, o, msg, args); // } // // public static void w(Object o, String msg, Object... args) { // log(Log.WARN, o, msg, args); // } // // public static void v(Object o, String msg, Object... args) { // log(Log.VERBOSE, o, msg, args); // } // // private static void log(int priority, Object o, String message, Object... args) { // log(priority, o, null, message, args); // } // // private static void log(int priority, Object o, Throwable throwable, String message, // Object... args) { // final boolean force = priority >= Log.WARN; // if (!force && !NEED_LOG) { // return; // } // // Log.println(priority, getTag(o), FileDownloadUtils.formatString(message, args)); // if (throwable != null) { // throwable.printStackTrace(); // } // } // // private static String getTag(final Object o) { // return TAG + ((o instanceof Class) // ? ((Class) o).getSimpleName() : o.getClass().getSimpleName()); // } // }
import com.liulishuo.filedownloader.util.FileDownloadLog;
/* * Copyright (c) 2015 LingoChamp Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.liulishuo.filedownloader.event; /** * An atom event. */ @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) public abstract class IDownloadEvent { public Runnable callback = null; public IDownloadEvent(final String id) { this.id = id; } /** * @see #IDownloadEvent(String) * @deprecated do not handle ORDER any more. */ public IDownloadEvent(final String id, boolean order) { this.id = id; if (order) {
// Path: library/src/main/java/com/liulishuo/filedownloader/util/FileDownloadLog.java // public class FileDownloadLog { // // public static boolean NEED_LOG = false; // // private static final String TAG = "FileDownloader."; // // public static void e(Object o, Throwable e, String msg, Object... args) { // log(Log.ERROR, o, e, msg, args); // } // // public static void e(Object o, String msg, Object... args) { // log(Log.ERROR, o, msg, args); // } // // public static void i(Object o, String msg, Object... args) { // log(Log.INFO, o, msg, args); // } // // public static void d(Object o, String msg, Object... args) { // log(Log.DEBUG, o, msg, args); // } // // public static void w(Object o, String msg, Object... args) { // log(Log.WARN, o, msg, args); // } // // public static void v(Object o, String msg, Object... args) { // log(Log.VERBOSE, o, msg, args); // } // // private static void log(int priority, Object o, String message, Object... args) { // log(priority, o, null, message, args); // } // // private static void log(int priority, Object o, Throwable throwable, String message, // Object... args) { // final boolean force = priority >= Log.WARN; // if (!force && !NEED_LOG) { // return; // } // // Log.println(priority, getTag(o), FileDownloadUtils.formatString(message, args)); // if (throwable != null) { // throwable.printStackTrace(); // } // } // // private static String getTag(final Object o) { // return TAG + ((o instanceof Class) // ? ((Class) o).getSimpleName() : o.getClass().getSimpleName()); // } // } // Path: library/src/main/java/com/liulishuo/filedownloader/event/IDownloadEvent.java import com.liulishuo.filedownloader.util.FileDownloadLog; /* * Copyright (c) 2015 LingoChamp Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.liulishuo.filedownloader.event; /** * An atom event. */ @SuppressWarnings({"WeakerAccess", "CanBeFinal"}) public abstract class IDownloadEvent { public Runnable callback = null; public IDownloadEvent(final String id) { this.id = id; } /** * @see #IDownloadEvent(String) * @deprecated do not handle ORDER any more. */ public IDownloadEvent(final String id, boolean order) { this.id = id; if (order) {
FileDownloadLog.w(this, "do not handle ORDER any more, %s", id);