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
|
---|---|---|---|---|---|---|
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ErrorsParser.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/dto/BitBucketError.java
// public class BitBucketError {
// private String message;
// private String context;
// private String exceptionName;
//
// public BitBucketError(String message, String context, String exceptionName) {
// this.context = context;
// this.message = message;
// this.exceptionName = exceptionName;
// }
//
// @Nullable
// public String getContext() {
// return context;
// }
//
// @Nullable
// public String getMessage() {
// return message;
// }
//
// @Nullable
// public String getExceptionName() {
// return exceptionName;
// }
//
// @Override
// public String toString() {
// return "BitBucketError{" +
// "message='" + message + '\'' +
// ", context='" + context + '\'' +
// ", exceptionName='" + exceptionName + '\'' +
// '}';
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, BitBucketError> errorParser() {
// return ERROR_PARSER;
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static <T> Function<JsonElement, List<T>> listParser(Function<JsonElement, T> elementParser) {
// return new ListParser<>(elementParser);
// }
| import com.ccreanga.bitbucket.rest.client.http.dto.BitBucketError;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.List;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.errorParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.listParser; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class ErrorsParser implements Function<JsonElement, List<BitBucketError>> {
@Override
public List<BitBucketError> apply(JsonElement input) {
JsonObject jsonObject = input.getAsJsonObject(); | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/dto/BitBucketError.java
// public class BitBucketError {
// private String message;
// private String context;
// private String exceptionName;
//
// public BitBucketError(String message, String context, String exceptionName) {
// this.context = context;
// this.message = message;
// this.exceptionName = exceptionName;
// }
//
// @Nullable
// public String getContext() {
// return context;
// }
//
// @Nullable
// public String getMessage() {
// return message;
// }
//
// @Nullable
// public String getExceptionName() {
// return exceptionName;
// }
//
// @Override
// public String toString() {
// return "BitBucketError{" +
// "message='" + message + '\'' +
// ", context='" + context + '\'' +
// ", exceptionName='" + exceptionName + '\'' +
// '}';
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, BitBucketError> errorParser() {
// return ERROR_PARSER;
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static <T> Function<JsonElement, List<T>> listParser(Function<JsonElement, T> elementParser) {
// return new ListParser<>(elementParser);
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ErrorsParser.java
import com.ccreanga.bitbucket.rest.client.http.dto.BitBucketError;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.List;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.errorParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.listParser;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class ErrorsParser implements Function<JsonElement, List<BitBucketError>> {
@Override
public List<BitBucketError> apply(JsonElement input) {
JsonObject jsonObject = input.getAsJsonObject(); | return listParser(errorParser()).apply(jsonObject.get("error")); |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/CommentParser.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Comment.java
// public class Comment implements Serializable {
//
// private long id;
// private long version;
// private String text;
// private User author;
// private Date created;
// private Date updated;
// private List<Comment> comments;
// private PermittedOperations permittedOperations;
//
// private Comment() {
// }
//
// public Comment(long id, long version, String text, User author, Date created, Date updated, List<Comment> comments, PermittedOperations permittedOperations) {
// this.id = id;
// this.version = version;
// this.text = text;
// this.author = author;
// this.created = created;
// this.updated = updated;
// this.comments = ImmutableList.copyOf(comments);
// this.permittedOperations = permittedOperations;
// }
//
// public long getId() {
// return id;
// }
//
// public long getVersion() {
// return version;
// }
//
// public String getText() {
// return text;
// }
//
// public User getAuthor() {
// return author;
// }
//
// public Date getCreated() {
// return created;
// }
//
// public Date getUpdated() {
// return updated;
// }
//
// public List<Comment> getComments() {
// return comments;
// }
//
// public PermittedOperations getPermittedOperations() {
// return permittedOperations;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Comment comment = (Comment) o;
// return Objects.equals(id, comment.id) &&
// Objects.equals(version, comment.version) &&
// Objects.equals(text, comment.text) &&
// Objects.equals(author, comment.author) &&
// Objects.equals(created, comment.created) &&
// Objects.equals(updated, comment.updated) &&
// Objects.equals(comments, comment.comments) &&
// Objects.equals(permittedOperations, comment.permittedOperations);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(id, version, text, author, created, updated, comments, permittedOperations);
// }
//
// @Override
// public String toString() {
// return "Comment{" +
// "id=" + id +
// ", version=" + version +
// ", text='" + text + '\'' +
// ", author=" + author +
// ", created=" + created +
// ", updated=" + updated +
// ", comments=" + comments +
// ", permittedOperations=" + permittedOperations +
// '}';
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, Comment> commentParser() {
// return COMMENT_PARSER;
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static <T> Function<JsonElement, List<T>> listParser(Function<JsonElement, T> elementParser) {
// return new ListParser<>(elementParser);
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement,PermittedOperations> permittedOperationsParser(){return PERMITTED_OPERATIONS_PARSER;}
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, User> userParser() {
// return USER_PARSER;
// }
| import com.ccreanga.bitbucket.rest.client.model.Comment;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.Date;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.commentParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.listParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.permittedOperationsParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.userParser; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class CommentParser implements Function<JsonElement, Comment> {
@Override
public Comment apply(JsonElement jsonElement) {
if (jsonElement == null || !jsonElement.isJsonObject()) {
return null;
}
JsonObject json = jsonElement.getAsJsonObject();
return new Comment(
json.get("id").getAsLong(),
json.get("version").getAsLong(),
json.get("text").getAsString(), | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Comment.java
// public class Comment implements Serializable {
//
// private long id;
// private long version;
// private String text;
// private User author;
// private Date created;
// private Date updated;
// private List<Comment> comments;
// private PermittedOperations permittedOperations;
//
// private Comment() {
// }
//
// public Comment(long id, long version, String text, User author, Date created, Date updated, List<Comment> comments, PermittedOperations permittedOperations) {
// this.id = id;
// this.version = version;
// this.text = text;
// this.author = author;
// this.created = created;
// this.updated = updated;
// this.comments = ImmutableList.copyOf(comments);
// this.permittedOperations = permittedOperations;
// }
//
// public long getId() {
// return id;
// }
//
// public long getVersion() {
// return version;
// }
//
// public String getText() {
// return text;
// }
//
// public User getAuthor() {
// return author;
// }
//
// public Date getCreated() {
// return created;
// }
//
// public Date getUpdated() {
// return updated;
// }
//
// public List<Comment> getComments() {
// return comments;
// }
//
// public PermittedOperations getPermittedOperations() {
// return permittedOperations;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Comment comment = (Comment) o;
// return Objects.equals(id, comment.id) &&
// Objects.equals(version, comment.version) &&
// Objects.equals(text, comment.text) &&
// Objects.equals(author, comment.author) &&
// Objects.equals(created, comment.created) &&
// Objects.equals(updated, comment.updated) &&
// Objects.equals(comments, comment.comments) &&
// Objects.equals(permittedOperations, comment.permittedOperations);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(id, version, text, author, created, updated, comments, permittedOperations);
// }
//
// @Override
// public String toString() {
// return "Comment{" +
// "id=" + id +
// ", version=" + version +
// ", text='" + text + '\'' +
// ", author=" + author +
// ", created=" + created +
// ", updated=" + updated +
// ", comments=" + comments +
// ", permittedOperations=" + permittedOperations +
// '}';
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, Comment> commentParser() {
// return COMMENT_PARSER;
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static <T> Function<JsonElement, List<T>> listParser(Function<JsonElement, T> elementParser) {
// return new ListParser<>(elementParser);
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement,PermittedOperations> permittedOperationsParser(){return PERMITTED_OPERATIONS_PARSER;}
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, User> userParser() {
// return USER_PARSER;
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/CommentParser.java
import com.ccreanga.bitbucket.rest.client.model.Comment;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.Date;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.commentParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.listParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.permittedOperationsParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.userParser;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class CommentParser implements Function<JsonElement, Comment> {
@Override
public Comment apply(JsonElement jsonElement) {
if (jsonElement == null || !jsonElement.isJsonObject()) {
return null;
}
JsonObject json = jsonElement.getAsJsonObject();
return new Comment(
json.get("id").getAsLong(),
json.get("version").getAsLong(),
json.get("text").getAsString(), | userParser().apply(json.getAsJsonObject("author")), |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/CommentParser.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Comment.java
// public class Comment implements Serializable {
//
// private long id;
// private long version;
// private String text;
// private User author;
// private Date created;
// private Date updated;
// private List<Comment> comments;
// private PermittedOperations permittedOperations;
//
// private Comment() {
// }
//
// public Comment(long id, long version, String text, User author, Date created, Date updated, List<Comment> comments, PermittedOperations permittedOperations) {
// this.id = id;
// this.version = version;
// this.text = text;
// this.author = author;
// this.created = created;
// this.updated = updated;
// this.comments = ImmutableList.copyOf(comments);
// this.permittedOperations = permittedOperations;
// }
//
// public long getId() {
// return id;
// }
//
// public long getVersion() {
// return version;
// }
//
// public String getText() {
// return text;
// }
//
// public User getAuthor() {
// return author;
// }
//
// public Date getCreated() {
// return created;
// }
//
// public Date getUpdated() {
// return updated;
// }
//
// public List<Comment> getComments() {
// return comments;
// }
//
// public PermittedOperations getPermittedOperations() {
// return permittedOperations;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Comment comment = (Comment) o;
// return Objects.equals(id, comment.id) &&
// Objects.equals(version, comment.version) &&
// Objects.equals(text, comment.text) &&
// Objects.equals(author, comment.author) &&
// Objects.equals(created, comment.created) &&
// Objects.equals(updated, comment.updated) &&
// Objects.equals(comments, comment.comments) &&
// Objects.equals(permittedOperations, comment.permittedOperations);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(id, version, text, author, created, updated, comments, permittedOperations);
// }
//
// @Override
// public String toString() {
// return "Comment{" +
// "id=" + id +
// ", version=" + version +
// ", text='" + text + '\'' +
// ", author=" + author +
// ", created=" + created +
// ", updated=" + updated +
// ", comments=" + comments +
// ", permittedOperations=" + permittedOperations +
// '}';
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, Comment> commentParser() {
// return COMMENT_PARSER;
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static <T> Function<JsonElement, List<T>> listParser(Function<JsonElement, T> elementParser) {
// return new ListParser<>(elementParser);
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement,PermittedOperations> permittedOperationsParser(){return PERMITTED_OPERATIONS_PARSER;}
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, User> userParser() {
// return USER_PARSER;
// }
| import com.ccreanga.bitbucket.rest.client.model.Comment;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.Date;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.commentParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.listParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.permittedOperationsParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.userParser; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class CommentParser implements Function<JsonElement, Comment> {
@Override
public Comment apply(JsonElement jsonElement) {
if (jsonElement == null || !jsonElement.isJsonObject()) {
return null;
}
JsonObject json = jsonElement.getAsJsonObject();
return new Comment(
json.get("id").getAsLong(),
json.get("version").getAsLong(),
json.get("text").getAsString(),
userParser().apply(json.getAsJsonObject("author")),
new Date(json.get("createdDate").getAsLong()),
new Date(json.get("updatedDate").getAsLong()), | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Comment.java
// public class Comment implements Serializable {
//
// private long id;
// private long version;
// private String text;
// private User author;
// private Date created;
// private Date updated;
// private List<Comment> comments;
// private PermittedOperations permittedOperations;
//
// private Comment() {
// }
//
// public Comment(long id, long version, String text, User author, Date created, Date updated, List<Comment> comments, PermittedOperations permittedOperations) {
// this.id = id;
// this.version = version;
// this.text = text;
// this.author = author;
// this.created = created;
// this.updated = updated;
// this.comments = ImmutableList.copyOf(comments);
// this.permittedOperations = permittedOperations;
// }
//
// public long getId() {
// return id;
// }
//
// public long getVersion() {
// return version;
// }
//
// public String getText() {
// return text;
// }
//
// public User getAuthor() {
// return author;
// }
//
// public Date getCreated() {
// return created;
// }
//
// public Date getUpdated() {
// return updated;
// }
//
// public List<Comment> getComments() {
// return comments;
// }
//
// public PermittedOperations getPermittedOperations() {
// return permittedOperations;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Comment comment = (Comment) o;
// return Objects.equals(id, comment.id) &&
// Objects.equals(version, comment.version) &&
// Objects.equals(text, comment.text) &&
// Objects.equals(author, comment.author) &&
// Objects.equals(created, comment.created) &&
// Objects.equals(updated, comment.updated) &&
// Objects.equals(comments, comment.comments) &&
// Objects.equals(permittedOperations, comment.permittedOperations);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(id, version, text, author, created, updated, comments, permittedOperations);
// }
//
// @Override
// public String toString() {
// return "Comment{" +
// "id=" + id +
// ", version=" + version +
// ", text='" + text + '\'' +
// ", author=" + author +
// ", created=" + created +
// ", updated=" + updated +
// ", comments=" + comments +
// ", permittedOperations=" + permittedOperations +
// '}';
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, Comment> commentParser() {
// return COMMENT_PARSER;
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static <T> Function<JsonElement, List<T>> listParser(Function<JsonElement, T> elementParser) {
// return new ListParser<>(elementParser);
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement,PermittedOperations> permittedOperationsParser(){return PERMITTED_OPERATIONS_PARSER;}
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, User> userParser() {
// return USER_PARSER;
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/CommentParser.java
import com.ccreanga.bitbucket.rest.client.model.Comment;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.Date;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.commentParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.listParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.permittedOperationsParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.userParser;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class CommentParser implements Function<JsonElement, Comment> {
@Override
public Comment apply(JsonElement jsonElement) {
if (jsonElement == null || !jsonElement.isJsonObject()) {
return null;
}
JsonObject json = jsonElement.getAsJsonObject();
return new Comment(
json.get("id").getAsLong(),
json.get("version").getAsLong(),
json.get("text").getAsString(),
userParser().apply(json.getAsJsonObject("author")),
new Date(json.get("createdDate").getAsLong()),
new Date(json.get("updatedDate").getAsLong()), | listParser(commentParser()).apply(json.get("comments")), |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/CommentParser.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Comment.java
// public class Comment implements Serializable {
//
// private long id;
// private long version;
// private String text;
// private User author;
// private Date created;
// private Date updated;
// private List<Comment> comments;
// private PermittedOperations permittedOperations;
//
// private Comment() {
// }
//
// public Comment(long id, long version, String text, User author, Date created, Date updated, List<Comment> comments, PermittedOperations permittedOperations) {
// this.id = id;
// this.version = version;
// this.text = text;
// this.author = author;
// this.created = created;
// this.updated = updated;
// this.comments = ImmutableList.copyOf(comments);
// this.permittedOperations = permittedOperations;
// }
//
// public long getId() {
// return id;
// }
//
// public long getVersion() {
// return version;
// }
//
// public String getText() {
// return text;
// }
//
// public User getAuthor() {
// return author;
// }
//
// public Date getCreated() {
// return created;
// }
//
// public Date getUpdated() {
// return updated;
// }
//
// public List<Comment> getComments() {
// return comments;
// }
//
// public PermittedOperations getPermittedOperations() {
// return permittedOperations;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Comment comment = (Comment) o;
// return Objects.equals(id, comment.id) &&
// Objects.equals(version, comment.version) &&
// Objects.equals(text, comment.text) &&
// Objects.equals(author, comment.author) &&
// Objects.equals(created, comment.created) &&
// Objects.equals(updated, comment.updated) &&
// Objects.equals(comments, comment.comments) &&
// Objects.equals(permittedOperations, comment.permittedOperations);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(id, version, text, author, created, updated, comments, permittedOperations);
// }
//
// @Override
// public String toString() {
// return "Comment{" +
// "id=" + id +
// ", version=" + version +
// ", text='" + text + '\'' +
// ", author=" + author +
// ", created=" + created +
// ", updated=" + updated +
// ", comments=" + comments +
// ", permittedOperations=" + permittedOperations +
// '}';
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, Comment> commentParser() {
// return COMMENT_PARSER;
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static <T> Function<JsonElement, List<T>> listParser(Function<JsonElement, T> elementParser) {
// return new ListParser<>(elementParser);
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement,PermittedOperations> permittedOperationsParser(){return PERMITTED_OPERATIONS_PARSER;}
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, User> userParser() {
// return USER_PARSER;
// }
| import com.ccreanga.bitbucket.rest.client.model.Comment;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.Date;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.commentParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.listParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.permittedOperationsParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.userParser; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class CommentParser implements Function<JsonElement, Comment> {
@Override
public Comment apply(JsonElement jsonElement) {
if (jsonElement == null || !jsonElement.isJsonObject()) {
return null;
}
JsonObject json = jsonElement.getAsJsonObject();
return new Comment(
json.get("id").getAsLong(),
json.get("version").getAsLong(),
json.get("text").getAsString(),
userParser().apply(json.getAsJsonObject("author")),
new Date(json.get("createdDate").getAsLong()),
new Date(json.get("updatedDate").getAsLong()), | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Comment.java
// public class Comment implements Serializable {
//
// private long id;
// private long version;
// private String text;
// private User author;
// private Date created;
// private Date updated;
// private List<Comment> comments;
// private PermittedOperations permittedOperations;
//
// private Comment() {
// }
//
// public Comment(long id, long version, String text, User author, Date created, Date updated, List<Comment> comments, PermittedOperations permittedOperations) {
// this.id = id;
// this.version = version;
// this.text = text;
// this.author = author;
// this.created = created;
// this.updated = updated;
// this.comments = ImmutableList.copyOf(comments);
// this.permittedOperations = permittedOperations;
// }
//
// public long getId() {
// return id;
// }
//
// public long getVersion() {
// return version;
// }
//
// public String getText() {
// return text;
// }
//
// public User getAuthor() {
// return author;
// }
//
// public Date getCreated() {
// return created;
// }
//
// public Date getUpdated() {
// return updated;
// }
//
// public List<Comment> getComments() {
// return comments;
// }
//
// public PermittedOperations getPermittedOperations() {
// return permittedOperations;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Comment comment = (Comment) o;
// return Objects.equals(id, comment.id) &&
// Objects.equals(version, comment.version) &&
// Objects.equals(text, comment.text) &&
// Objects.equals(author, comment.author) &&
// Objects.equals(created, comment.created) &&
// Objects.equals(updated, comment.updated) &&
// Objects.equals(comments, comment.comments) &&
// Objects.equals(permittedOperations, comment.permittedOperations);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(id, version, text, author, created, updated, comments, permittedOperations);
// }
//
// @Override
// public String toString() {
// return "Comment{" +
// "id=" + id +
// ", version=" + version +
// ", text='" + text + '\'' +
// ", author=" + author +
// ", created=" + created +
// ", updated=" + updated +
// ", comments=" + comments +
// ", permittedOperations=" + permittedOperations +
// '}';
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, Comment> commentParser() {
// return COMMENT_PARSER;
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static <T> Function<JsonElement, List<T>> listParser(Function<JsonElement, T> elementParser) {
// return new ListParser<>(elementParser);
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement,PermittedOperations> permittedOperationsParser(){return PERMITTED_OPERATIONS_PARSER;}
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, User> userParser() {
// return USER_PARSER;
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/CommentParser.java
import com.ccreanga.bitbucket.rest.client.model.Comment;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.Date;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.commentParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.listParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.permittedOperationsParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.userParser;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class CommentParser implements Function<JsonElement, Comment> {
@Override
public Comment apply(JsonElement jsonElement) {
if (jsonElement == null || !jsonElement.isJsonObject()) {
return null;
}
JsonObject json = jsonElement.getAsJsonObject();
return new Comment(
json.get("id").getAsLong(),
json.get("version").getAsLong(),
json.get("text").getAsString(),
userParser().apply(json.getAsJsonObject("author")),
new Date(json.get("createdDate").getAsLong()),
new Date(json.get("updatedDate").getAsLong()), | listParser(commentParser()).apply(json.get("comments")), |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/CommentParser.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Comment.java
// public class Comment implements Serializable {
//
// private long id;
// private long version;
// private String text;
// private User author;
// private Date created;
// private Date updated;
// private List<Comment> comments;
// private PermittedOperations permittedOperations;
//
// private Comment() {
// }
//
// public Comment(long id, long version, String text, User author, Date created, Date updated, List<Comment> comments, PermittedOperations permittedOperations) {
// this.id = id;
// this.version = version;
// this.text = text;
// this.author = author;
// this.created = created;
// this.updated = updated;
// this.comments = ImmutableList.copyOf(comments);
// this.permittedOperations = permittedOperations;
// }
//
// public long getId() {
// return id;
// }
//
// public long getVersion() {
// return version;
// }
//
// public String getText() {
// return text;
// }
//
// public User getAuthor() {
// return author;
// }
//
// public Date getCreated() {
// return created;
// }
//
// public Date getUpdated() {
// return updated;
// }
//
// public List<Comment> getComments() {
// return comments;
// }
//
// public PermittedOperations getPermittedOperations() {
// return permittedOperations;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Comment comment = (Comment) o;
// return Objects.equals(id, comment.id) &&
// Objects.equals(version, comment.version) &&
// Objects.equals(text, comment.text) &&
// Objects.equals(author, comment.author) &&
// Objects.equals(created, comment.created) &&
// Objects.equals(updated, comment.updated) &&
// Objects.equals(comments, comment.comments) &&
// Objects.equals(permittedOperations, comment.permittedOperations);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(id, version, text, author, created, updated, comments, permittedOperations);
// }
//
// @Override
// public String toString() {
// return "Comment{" +
// "id=" + id +
// ", version=" + version +
// ", text='" + text + '\'' +
// ", author=" + author +
// ", created=" + created +
// ", updated=" + updated +
// ", comments=" + comments +
// ", permittedOperations=" + permittedOperations +
// '}';
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, Comment> commentParser() {
// return COMMENT_PARSER;
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static <T> Function<JsonElement, List<T>> listParser(Function<JsonElement, T> elementParser) {
// return new ListParser<>(elementParser);
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement,PermittedOperations> permittedOperationsParser(){return PERMITTED_OPERATIONS_PARSER;}
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, User> userParser() {
// return USER_PARSER;
// }
| import com.ccreanga.bitbucket.rest.client.model.Comment;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.Date;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.commentParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.listParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.permittedOperationsParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.userParser; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class CommentParser implements Function<JsonElement, Comment> {
@Override
public Comment apply(JsonElement jsonElement) {
if (jsonElement == null || !jsonElement.isJsonObject()) {
return null;
}
JsonObject json = jsonElement.getAsJsonObject();
return new Comment(
json.get("id").getAsLong(),
json.get("version").getAsLong(),
json.get("text").getAsString(),
userParser().apply(json.getAsJsonObject("author")),
new Date(json.get("createdDate").getAsLong()),
new Date(json.get("updatedDate").getAsLong()),
listParser(commentParser()).apply(json.get("comments")), | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Comment.java
// public class Comment implements Serializable {
//
// private long id;
// private long version;
// private String text;
// private User author;
// private Date created;
// private Date updated;
// private List<Comment> comments;
// private PermittedOperations permittedOperations;
//
// private Comment() {
// }
//
// public Comment(long id, long version, String text, User author, Date created, Date updated, List<Comment> comments, PermittedOperations permittedOperations) {
// this.id = id;
// this.version = version;
// this.text = text;
// this.author = author;
// this.created = created;
// this.updated = updated;
// this.comments = ImmutableList.copyOf(comments);
// this.permittedOperations = permittedOperations;
// }
//
// public long getId() {
// return id;
// }
//
// public long getVersion() {
// return version;
// }
//
// public String getText() {
// return text;
// }
//
// public User getAuthor() {
// return author;
// }
//
// public Date getCreated() {
// return created;
// }
//
// public Date getUpdated() {
// return updated;
// }
//
// public List<Comment> getComments() {
// return comments;
// }
//
// public PermittedOperations getPermittedOperations() {
// return permittedOperations;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Comment comment = (Comment) o;
// return Objects.equals(id, comment.id) &&
// Objects.equals(version, comment.version) &&
// Objects.equals(text, comment.text) &&
// Objects.equals(author, comment.author) &&
// Objects.equals(created, comment.created) &&
// Objects.equals(updated, comment.updated) &&
// Objects.equals(comments, comment.comments) &&
// Objects.equals(permittedOperations, comment.permittedOperations);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(id, version, text, author, created, updated, comments, permittedOperations);
// }
//
// @Override
// public String toString() {
// return "Comment{" +
// "id=" + id +
// ", version=" + version +
// ", text='" + text + '\'' +
// ", author=" + author +
// ", created=" + created +
// ", updated=" + updated +
// ", comments=" + comments +
// ", permittedOperations=" + permittedOperations +
// '}';
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, Comment> commentParser() {
// return COMMENT_PARSER;
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static <T> Function<JsonElement, List<T>> listParser(Function<JsonElement, T> elementParser) {
// return new ListParser<>(elementParser);
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement,PermittedOperations> permittedOperationsParser(){return PERMITTED_OPERATIONS_PARSER;}
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, User> userParser() {
// return USER_PARSER;
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/CommentParser.java
import com.ccreanga.bitbucket.rest.client.model.Comment;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.Date;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.commentParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.listParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.permittedOperationsParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.userParser;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class CommentParser implements Function<JsonElement, Comment> {
@Override
public Comment apply(JsonElement jsonElement) {
if (jsonElement == null || !jsonElement.isJsonObject()) {
return null;
}
JsonObject json = jsonElement.getAsJsonObject();
return new Comment(
json.get("id").getAsLong(),
json.get("version").getAsLong(),
json.get("text").getAsString(),
userParser().apply(json.getAsJsonObject("author")),
new Date(json.get("createdDate").getAsLong()),
new Date(json.get("updatedDate").getAsLong()),
listParser(commentParser()).apply(json.get("comments")), | permittedOperationsParser().apply(json.getAsJsonObject("permittedOperations")) |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/TaskParser.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Task.java
// public class Task implements Serializable {
//
// private long id;
// private TaskState taskState;
// private String text;
// private Date created;
// private Comment comment;
// private User user;
// private TaskOperations taskOperations;
//
// private Task() {
// }
//
// public Task(long id, TaskState taskState, String text, Date created, Comment comment, User user, TaskOperations taskOperations) {
// this.id = id;
// this.taskState = taskState;
// this.text = text;
// this.created = created;
// this.comment = comment;
// this.user = user;
// this.taskOperations = taskOperations;
// }
//
// public long getId() {
// return id;
// }
//
// public TaskState getTaskState() {
// return taskState;
// }
//
// public String getText() {
// return text;
// }
//
// public Date getCreated() {
// return created;
// }
//
// public Comment getComment() {
// return comment;
// }
//
// public User getUser() {
// return user;
// }
//
// public TaskOperations getTaskOperations() {
// return taskOperations;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Task task = (Task) o;
// return Objects.equals(id, task.id) &&
// Objects.equals(taskState, task.taskState) &&
// Objects.equals(text, task.text) &&
// Objects.equals(created, task.created) &&
// Objects.equals(comment, task.comment) &&
// Objects.equals(user, task.user) &&
// Objects.equals(taskOperations, task.taskOperations);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(id, taskState, text, created, comment, user, taskOperations);
// }
//
// @Override
// public String toString() {
// return "Task{" +
// "id=" + id +
// ", taskState=" + taskState +
// ", text='" + text + '\'' +
// ", created=" + created +
// ", comment=" + comment +
// ", user=" + user +
// ", taskOperations=" + taskOperations +
// '}';
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/TaskState.java
// public enum TaskState implements Serializable {
// OPEN,RESOLVED
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, Comment> commentParser() {
// return COMMENT_PARSER;
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement,TaskOperations> taskOperationsParser(){return TASK_OPERATIONS_PARSER;}
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, User> userParser() {
// return USER_PARSER;
// }
| import com.ccreanga.bitbucket.rest.client.model.Task;
import com.ccreanga.bitbucket.rest.client.model.TaskState;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.Date;
import java.util.function.Function;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.commentParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.taskOperationsParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.userParser; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class TaskParser implements Function<JsonElement, Task> {
@Override
public Task apply(JsonElement jsonElement) {
if (jsonElement == null || !jsonElement.isJsonObject()) {
return null;
}
JsonObject json = jsonElement.getAsJsonObject();
return new Task(
json.get("id").getAsLong(), | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Task.java
// public class Task implements Serializable {
//
// private long id;
// private TaskState taskState;
// private String text;
// private Date created;
// private Comment comment;
// private User user;
// private TaskOperations taskOperations;
//
// private Task() {
// }
//
// public Task(long id, TaskState taskState, String text, Date created, Comment comment, User user, TaskOperations taskOperations) {
// this.id = id;
// this.taskState = taskState;
// this.text = text;
// this.created = created;
// this.comment = comment;
// this.user = user;
// this.taskOperations = taskOperations;
// }
//
// public long getId() {
// return id;
// }
//
// public TaskState getTaskState() {
// return taskState;
// }
//
// public String getText() {
// return text;
// }
//
// public Date getCreated() {
// return created;
// }
//
// public Comment getComment() {
// return comment;
// }
//
// public User getUser() {
// return user;
// }
//
// public TaskOperations getTaskOperations() {
// return taskOperations;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Task task = (Task) o;
// return Objects.equals(id, task.id) &&
// Objects.equals(taskState, task.taskState) &&
// Objects.equals(text, task.text) &&
// Objects.equals(created, task.created) &&
// Objects.equals(comment, task.comment) &&
// Objects.equals(user, task.user) &&
// Objects.equals(taskOperations, task.taskOperations);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(id, taskState, text, created, comment, user, taskOperations);
// }
//
// @Override
// public String toString() {
// return "Task{" +
// "id=" + id +
// ", taskState=" + taskState +
// ", text='" + text + '\'' +
// ", created=" + created +
// ", comment=" + comment +
// ", user=" + user +
// ", taskOperations=" + taskOperations +
// '}';
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/TaskState.java
// public enum TaskState implements Serializable {
// OPEN,RESOLVED
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, Comment> commentParser() {
// return COMMENT_PARSER;
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement,TaskOperations> taskOperationsParser(){return TASK_OPERATIONS_PARSER;}
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, User> userParser() {
// return USER_PARSER;
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/TaskParser.java
import com.ccreanga.bitbucket.rest.client.model.Task;
import com.ccreanga.bitbucket.rest.client.model.TaskState;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.Date;
import java.util.function.Function;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.commentParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.taskOperationsParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.userParser;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class TaskParser implements Function<JsonElement, Task> {
@Override
public Task apply(JsonElement jsonElement) {
if (jsonElement == null || !jsonElement.isJsonObject()) {
return null;
}
JsonObject json = jsonElement.getAsJsonObject();
return new Task(
json.get("id").getAsLong(), | TaskState.valueOf(json.get("state").getAsString()), |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/TaskParser.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Task.java
// public class Task implements Serializable {
//
// private long id;
// private TaskState taskState;
// private String text;
// private Date created;
// private Comment comment;
// private User user;
// private TaskOperations taskOperations;
//
// private Task() {
// }
//
// public Task(long id, TaskState taskState, String text, Date created, Comment comment, User user, TaskOperations taskOperations) {
// this.id = id;
// this.taskState = taskState;
// this.text = text;
// this.created = created;
// this.comment = comment;
// this.user = user;
// this.taskOperations = taskOperations;
// }
//
// public long getId() {
// return id;
// }
//
// public TaskState getTaskState() {
// return taskState;
// }
//
// public String getText() {
// return text;
// }
//
// public Date getCreated() {
// return created;
// }
//
// public Comment getComment() {
// return comment;
// }
//
// public User getUser() {
// return user;
// }
//
// public TaskOperations getTaskOperations() {
// return taskOperations;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Task task = (Task) o;
// return Objects.equals(id, task.id) &&
// Objects.equals(taskState, task.taskState) &&
// Objects.equals(text, task.text) &&
// Objects.equals(created, task.created) &&
// Objects.equals(comment, task.comment) &&
// Objects.equals(user, task.user) &&
// Objects.equals(taskOperations, task.taskOperations);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(id, taskState, text, created, comment, user, taskOperations);
// }
//
// @Override
// public String toString() {
// return "Task{" +
// "id=" + id +
// ", taskState=" + taskState +
// ", text='" + text + '\'' +
// ", created=" + created +
// ", comment=" + comment +
// ", user=" + user +
// ", taskOperations=" + taskOperations +
// '}';
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/TaskState.java
// public enum TaskState implements Serializable {
// OPEN,RESOLVED
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, Comment> commentParser() {
// return COMMENT_PARSER;
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement,TaskOperations> taskOperationsParser(){return TASK_OPERATIONS_PARSER;}
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, User> userParser() {
// return USER_PARSER;
// }
| import com.ccreanga.bitbucket.rest.client.model.Task;
import com.ccreanga.bitbucket.rest.client.model.TaskState;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.Date;
import java.util.function.Function;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.commentParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.taskOperationsParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.userParser; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class TaskParser implements Function<JsonElement, Task> {
@Override
public Task apply(JsonElement jsonElement) {
if (jsonElement == null || !jsonElement.isJsonObject()) {
return null;
}
JsonObject json = jsonElement.getAsJsonObject();
return new Task(
json.get("id").getAsLong(),
TaskState.valueOf(json.get("state").getAsString()),
json.get("text").getAsString(),
new Date(json.get("createdDate").getAsLong()), | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Task.java
// public class Task implements Serializable {
//
// private long id;
// private TaskState taskState;
// private String text;
// private Date created;
// private Comment comment;
// private User user;
// private TaskOperations taskOperations;
//
// private Task() {
// }
//
// public Task(long id, TaskState taskState, String text, Date created, Comment comment, User user, TaskOperations taskOperations) {
// this.id = id;
// this.taskState = taskState;
// this.text = text;
// this.created = created;
// this.comment = comment;
// this.user = user;
// this.taskOperations = taskOperations;
// }
//
// public long getId() {
// return id;
// }
//
// public TaskState getTaskState() {
// return taskState;
// }
//
// public String getText() {
// return text;
// }
//
// public Date getCreated() {
// return created;
// }
//
// public Comment getComment() {
// return comment;
// }
//
// public User getUser() {
// return user;
// }
//
// public TaskOperations getTaskOperations() {
// return taskOperations;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Task task = (Task) o;
// return Objects.equals(id, task.id) &&
// Objects.equals(taskState, task.taskState) &&
// Objects.equals(text, task.text) &&
// Objects.equals(created, task.created) &&
// Objects.equals(comment, task.comment) &&
// Objects.equals(user, task.user) &&
// Objects.equals(taskOperations, task.taskOperations);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(id, taskState, text, created, comment, user, taskOperations);
// }
//
// @Override
// public String toString() {
// return "Task{" +
// "id=" + id +
// ", taskState=" + taskState +
// ", text='" + text + '\'' +
// ", created=" + created +
// ", comment=" + comment +
// ", user=" + user +
// ", taskOperations=" + taskOperations +
// '}';
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/TaskState.java
// public enum TaskState implements Serializable {
// OPEN,RESOLVED
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, Comment> commentParser() {
// return COMMENT_PARSER;
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement,TaskOperations> taskOperationsParser(){return TASK_OPERATIONS_PARSER;}
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, User> userParser() {
// return USER_PARSER;
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/TaskParser.java
import com.ccreanga.bitbucket.rest.client.model.Task;
import com.ccreanga.bitbucket.rest.client.model.TaskState;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.Date;
import java.util.function.Function;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.commentParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.taskOperationsParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.userParser;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class TaskParser implements Function<JsonElement, Task> {
@Override
public Task apply(JsonElement jsonElement) {
if (jsonElement == null || !jsonElement.isJsonObject()) {
return null;
}
JsonObject json = jsonElement.getAsJsonObject();
return new Task(
json.get("id").getAsLong(),
TaskState.valueOf(json.get("state").getAsString()),
json.get("text").getAsString(),
new Date(json.get("createdDate").getAsLong()), | commentParser().apply(json.getAsJsonObject("anchor")), |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/TaskParser.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Task.java
// public class Task implements Serializable {
//
// private long id;
// private TaskState taskState;
// private String text;
// private Date created;
// private Comment comment;
// private User user;
// private TaskOperations taskOperations;
//
// private Task() {
// }
//
// public Task(long id, TaskState taskState, String text, Date created, Comment comment, User user, TaskOperations taskOperations) {
// this.id = id;
// this.taskState = taskState;
// this.text = text;
// this.created = created;
// this.comment = comment;
// this.user = user;
// this.taskOperations = taskOperations;
// }
//
// public long getId() {
// return id;
// }
//
// public TaskState getTaskState() {
// return taskState;
// }
//
// public String getText() {
// return text;
// }
//
// public Date getCreated() {
// return created;
// }
//
// public Comment getComment() {
// return comment;
// }
//
// public User getUser() {
// return user;
// }
//
// public TaskOperations getTaskOperations() {
// return taskOperations;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Task task = (Task) o;
// return Objects.equals(id, task.id) &&
// Objects.equals(taskState, task.taskState) &&
// Objects.equals(text, task.text) &&
// Objects.equals(created, task.created) &&
// Objects.equals(comment, task.comment) &&
// Objects.equals(user, task.user) &&
// Objects.equals(taskOperations, task.taskOperations);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(id, taskState, text, created, comment, user, taskOperations);
// }
//
// @Override
// public String toString() {
// return "Task{" +
// "id=" + id +
// ", taskState=" + taskState +
// ", text='" + text + '\'' +
// ", created=" + created +
// ", comment=" + comment +
// ", user=" + user +
// ", taskOperations=" + taskOperations +
// '}';
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/TaskState.java
// public enum TaskState implements Serializable {
// OPEN,RESOLVED
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, Comment> commentParser() {
// return COMMENT_PARSER;
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement,TaskOperations> taskOperationsParser(){return TASK_OPERATIONS_PARSER;}
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, User> userParser() {
// return USER_PARSER;
// }
| import com.ccreanga.bitbucket.rest.client.model.Task;
import com.ccreanga.bitbucket.rest.client.model.TaskState;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.Date;
import java.util.function.Function;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.commentParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.taskOperationsParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.userParser; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class TaskParser implements Function<JsonElement, Task> {
@Override
public Task apply(JsonElement jsonElement) {
if (jsonElement == null || !jsonElement.isJsonObject()) {
return null;
}
JsonObject json = jsonElement.getAsJsonObject();
return new Task(
json.get("id").getAsLong(),
TaskState.valueOf(json.get("state").getAsString()),
json.get("text").getAsString(),
new Date(json.get("createdDate").getAsLong()),
commentParser().apply(json.getAsJsonObject("anchor")), | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Task.java
// public class Task implements Serializable {
//
// private long id;
// private TaskState taskState;
// private String text;
// private Date created;
// private Comment comment;
// private User user;
// private TaskOperations taskOperations;
//
// private Task() {
// }
//
// public Task(long id, TaskState taskState, String text, Date created, Comment comment, User user, TaskOperations taskOperations) {
// this.id = id;
// this.taskState = taskState;
// this.text = text;
// this.created = created;
// this.comment = comment;
// this.user = user;
// this.taskOperations = taskOperations;
// }
//
// public long getId() {
// return id;
// }
//
// public TaskState getTaskState() {
// return taskState;
// }
//
// public String getText() {
// return text;
// }
//
// public Date getCreated() {
// return created;
// }
//
// public Comment getComment() {
// return comment;
// }
//
// public User getUser() {
// return user;
// }
//
// public TaskOperations getTaskOperations() {
// return taskOperations;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Task task = (Task) o;
// return Objects.equals(id, task.id) &&
// Objects.equals(taskState, task.taskState) &&
// Objects.equals(text, task.text) &&
// Objects.equals(created, task.created) &&
// Objects.equals(comment, task.comment) &&
// Objects.equals(user, task.user) &&
// Objects.equals(taskOperations, task.taskOperations);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(id, taskState, text, created, comment, user, taskOperations);
// }
//
// @Override
// public String toString() {
// return "Task{" +
// "id=" + id +
// ", taskState=" + taskState +
// ", text='" + text + '\'' +
// ", created=" + created +
// ", comment=" + comment +
// ", user=" + user +
// ", taskOperations=" + taskOperations +
// '}';
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/TaskState.java
// public enum TaskState implements Serializable {
// OPEN,RESOLVED
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, Comment> commentParser() {
// return COMMENT_PARSER;
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement,TaskOperations> taskOperationsParser(){return TASK_OPERATIONS_PARSER;}
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, User> userParser() {
// return USER_PARSER;
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/TaskParser.java
import com.ccreanga.bitbucket.rest.client.model.Task;
import com.ccreanga.bitbucket.rest.client.model.TaskState;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.Date;
import java.util.function.Function;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.commentParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.taskOperationsParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.userParser;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class TaskParser implements Function<JsonElement, Task> {
@Override
public Task apply(JsonElement jsonElement) {
if (jsonElement == null || !jsonElement.isJsonObject()) {
return null;
}
JsonObject json = jsonElement.getAsJsonObject();
return new Task(
json.get("id").getAsLong(),
TaskState.valueOf(json.get("state").getAsString()),
json.get("text").getAsString(),
new Date(json.get("createdDate").getAsLong()),
commentParser().apply(json.getAsJsonObject("anchor")), | userParser().apply(json.getAsJsonObject("author")), |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/TaskParser.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Task.java
// public class Task implements Serializable {
//
// private long id;
// private TaskState taskState;
// private String text;
// private Date created;
// private Comment comment;
// private User user;
// private TaskOperations taskOperations;
//
// private Task() {
// }
//
// public Task(long id, TaskState taskState, String text, Date created, Comment comment, User user, TaskOperations taskOperations) {
// this.id = id;
// this.taskState = taskState;
// this.text = text;
// this.created = created;
// this.comment = comment;
// this.user = user;
// this.taskOperations = taskOperations;
// }
//
// public long getId() {
// return id;
// }
//
// public TaskState getTaskState() {
// return taskState;
// }
//
// public String getText() {
// return text;
// }
//
// public Date getCreated() {
// return created;
// }
//
// public Comment getComment() {
// return comment;
// }
//
// public User getUser() {
// return user;
// }
//
// public TaskOperations getTaskOperations() {
// return taskOperations;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Task task = (Task) o;
// return Objects.equals(id, task.id) &&
// Objects.equals(taskState, task.taskState) &&
// Objects.equals(text, task.text) &&
// Objects.equals(created, task.created) &&
// Objects.equals(comment, task.comment) &&
// Objects.equals(user, task.user) &&
// Objects.equals(taskOperations, task.taskOperations);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(id, taskState, text, created, comment, user, taskOperations);
// }
//
// @Override
// public String toString() {
// return "Task{" +
// "id=" + id +
// ", taskState=" + taskState +
// ", text='" + text + '\'' +
// ", created=" + created +
// ", comment=" + comment +
// ", user=" + user +
// ", taskOperations=" + taskOperations +
// '}';
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/TaskState.java
// public enum TaskState implements Serializable {
// OPEN,RESOLVED
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, Comment> commentParser() {
// return COMMENT_PARSER;
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement,TaskOperations> taskOperationsParser(){return TASK_OPERATIONS_PARSER;}
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, User> userParser() {
// return USER_PARSER;
// }
| import com.ccreanga.bitbucket.rest.client.model.Task;
import com.ccreanga.bitbucket.rest.client.model.TaskState;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.Date;
import java.util.function.Function;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.commentParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.taskOperationsParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.userParser; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class TaskParser implements Function<JsonElement, Task> {
@Override
public Task apply(JsonElement jsonElement) {
if (jsonElement == null || !jsonElement.isJsonObject()) {
return null;
}
JsonObject json = jsonElement.getAsJsonObject();
return new Task(
json.get("id").getAsLong(),
TaskState.valueOf(json.get("state").getAsString()),
json.get("text").getAsString(),
new Date(json.get("createdDate").getAsLong()),
commentParser().apply(json.getAsJsonObject("anchor")),
userParser().apply(json.getAsJsonObject("author")), | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Task.java
// public class Task implements Serializable {
//
// private long id;
// private TaskState taskState;
// private String text;
// private Date created;
// private Comment comment;
// private User user;
// private TaskOperations taskOperations;
//
// private Task() {
// }
//
// public Task(long id, TaskState taskState, String text, Date created, Comment comment, User user, TaskOperations taskOperations) {
// this.id = id;
// this.taskState = taskState;
// this.text = text;
// this.created = created;
// this.comment = comment;
// this.user = user;
// this.taskOperations = taskOperations;
// }
//
// public long getId() {
// return id;
// }
//
// public TaskState getTaskState() {
// return taskState;
// }
//
// public String getText() {
// return text;
// }
//
// public Date getCreated() {
// return created;
// }
//
// public Comment getComment() {
// return comment;
// }
//
// public User getUser() {
// return user;
// }
//
// public TaskOperations getTaskOperations() {
// return taskOperations;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Task task = (Task) o;
// return Objects.equals(id, task.id) &&
// Objects.equals(taskState, task.taskState) &&
// Objects.equals(text, task.text) &&
// Objects.equals(created, task.created) &&
// Objects.equals(comment, task.comment) &&
// Objects.equals(user, task.user) &&
// Objects.equals(taskOperations, task.taskOperations);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(id, taskState, text, created, comment, user, taskOperations);
// }
//
// @Override
// public String toString() {
// return "Task{" +
// "id=" + id +
// ", taskState=" + taskState +
// ", text='" + text + '\'' +
// ", created=" + created +
// ", comment=" + comment +
// ", user=" + user +
// ", taskOperations=" + taskOperations +
// '}';
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/TaskState.java
// public enum TaskState implements Serializable {
// OPEN,RESOLVED
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, Comment> commentParser() {
// return COMMENT_PARSER;
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement,TaskOperations> taskOperationsParser(){return TASK_OPERATIONS_PARSER;}
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, User> userParser() {
// return USER_PARSER;
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/TaskParser.java
import com.ccreanga.bitbucket.rest.client.model.Task;
import com.ccreanga.bitbucket.rest.client.model.TaskState;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.Date;
import java.util.function.Function;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.commentParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.taskOperationsParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.userParser;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class TaskParser implements Function<JsonElement, Task> {
@Override
public Task apply(JsonElement jsonElement) {
if (jsonElement == null || !jsonElement.isJsonObject()) {
return null;
}
JsonObject json = jsonElement.getAsJsonObject();
return new Task(
json.get("id").getAsLong(),
TaskState.valueOf(json.get("state").getAsString()),
json.get("text").getAsString(),
new Date(json.get("createdDate").getAsLong()),
commentParser().apply(json.getAsJsonObject("anchor")),
userParser().apply(json.getAsJsonObject("author")), | taskOperationsParser().apply(json.getAsJsonObject("permittedOperations")) |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/http/GenericException.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/dto/BitBucketError.java
// public class BitBucketError {
// private String message;
// private String context;
// private String exceptionName;
//
// public BitBucketError(String message, String context, String exceptionName) {
// this.context = context;
// this.message = message;
// this.exceptionName = exceptionName;
// }
//
// @Nullable
// public String getContext() {
// return context;
// }
//
// @Nullable
// public String getMessage() {
// return message;
// }
//
// @Nullable
// public String getExceptionName() {
// return exceptionName;
// }
//
// @Override
// public String toString() {
// return "BitBucketError{" +
// "message='" + message + '\'' +
// ", context='" + context + '\'' +
// ", exceptionName='" + exceptionName + '\'' +
// '}';
// }
// }
| import com.ccreanga.bitbucket.rest.client.http.dto.BitBucketError;
import javax.annotation.Nullable;
import java.util.List; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http;
public class GenericException extends BitBucketException {
private int statusCode;
private String statusMessage;
private String responseBody;
| // Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/dto/BitBucketError.java
// public class BitBucketError {
// private String message;
// private String context;
// private String exceptionName;
//
// public BitBucketError(String message, String context, String exceptionName) {
// this.context = context;
// this.message = message;
// this.exceptionName = exceptionName;
// }
//
// @Nullable
// public String getContext() {
// return context;
// }
//
// @Nullable
// public String getMessage() {
// return message;
// }
//
// @Nullable
// public String getExceptionName() {
// return exceptionName;
// }
//
// @Override
// public String toString() {
// return "BitBucketError{" +
// "message='" + message + '\'' +
// ", context='" + context + '\'' +
// ", exceptionName='" + exceptionName + '\'' +
// '}';
// }
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/GenericException.java
import com.ccreanga.bitbucket.rest.client.http.dto.BitBucketError;
import javax.annotation.Nullable;
import java.util.List;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http;
public class GenericException extends BitBucketException {
private int statusCode;
private String statusMessage;
private String responseBody;
| public GenericException(List<BitBucketError> errors, int statusCode, String statusMessage, String responseBody) { |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/CommitParser.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Commit.java
// public class Commit implements Serializable {
//
// private String id;
// private String displayId;
// private String authorName;
// private String authorEmail;
// private long authorTimestamp;
// private String message;
// private List<MinimalCommit> parentsIds;
//
// private Commit() {
// }
//
// public Commit(String id, String displayId, String authorName, String authorEmail, long authorTimestamp, String message, List<MinimalCommit> parentsIds) {
// this.id = id;
// this.displayId = displayId;
// this.authorName = authorName;
// this.authorEmail = authorEmail;
// this.authorTimestamp = authorTimestamp;
// this.message = message;
// this.parentsIds = ImmutableList.copyOf(parentsIds);
// }
//
// public String getId() {
// return id;
// }
//
// public String getDisplayId() {
// return displayId;
// }
//
// public String getAuthorName() {
// return authorName;
// }
//
// public String getAuthorEmail() {
// return authorEmail;
// }
//
// public long getAuthorTimestamp() {
// return authorTimestamp;
// }
//
// public String getMessage() {
// return message;
// }
//
// public List<MinimalCommit> getParentsIds() {
// return parentsIds;
// }
//
// @Override
// public String toString() {
// return "Commit{" +
// "id='" + id + '\'' +
// ", displayId='" + displayId + '\'' +
// ", authorName='" + authorName + '\'' +
// ", authorEmail='" + authorEmail + '\'' +
// ", authorTimestamp=" + authorTimestamp +
// ", message='" + message + '\'' +
// ", parentsIds=" + parentsIds +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Commit changeSet = (Commit) o;
// return Objects.equals(authorTimestamp, changeSet.authorTimestamp) &&
// Objects.equals(id, changeSet.id) &&
// Objects.equals(displayId, changeSet.displayId) &&
// Objects.equals(authorName, changeSet.authorName) &&
// Objects.equals(authorEmail, changeSet.authorEmail) &&
// Objects.equals(message, changeSet.message) &&
// Objects.equals(parentsIds, changeSet.parentsIds);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(id, displayId, authorName, authorEmail, authorTimestamp, message, parentsIds);
// }
//
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static <T> Function<JsonElement, List<T>> listParser(Function<JsonElement, T> elementParser) {
// return new ListParser<>(elementParser);
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, MinimalCommit> minimalCommitParser() {
// return MINIMAL_COMMIT_PARSER;
// }
| import com.ccreanga.bitbucket.rest.client.model.Commit;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.listParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.minimalCommitParser; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class CommitParser implements Function<JsonElement, Commit> {
@Override
public Commit apply(JsonElement jsonElement) {
if (jsonElement == null || !jsonElement.isJsonObject()) {
return null;
}
JsonObject json = jsonElement.getAsJsonObject();
return new Commit(
json.get("id").getAsString(),
json.get("displayId").getAsString(),
json.get("author").getAsJsonObject().get("name").getAsString(),
json.get("author").getAsJsonObject().get("emailAddress").getAsString(),
json.get("authorTimestamp").getAsLong(),
json.get("message").getAsString(), | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Commit.java
// public class Commit implements Serializable {
//
// private String id;
// private String displayId;
// private String authorName;
// private String authorEmail;
// private long authorTimestamp;
// private String message;
// private List<MinimalCommit> parentsIds;
//
// private Commit() {
// }
//
// public Commit(String id, String displayId, String authorName, String authorEmail, long authorTimestamp, String message, List<MinimalCommit> parentsIds) {
// this.id = id;
// this.displayId = displayId;
// this.authorName = authorName;
// this.authorEmail = authorEmail;
// this.authorTimestamp = authorTimestamp;
// this.message = message;
// this.parentsIds = ImmutableList.copyOf(parentsIds);
// }
//
// public String getId() {
// return id;
// }
//
// public String getDisplayId() {
// return displayId;
// }
//
// public String getAuthorName() {
// return authorName;
// }
//
// public String getAuthorEmail() {
// return authorEmail;
// }
//
// public long getAuthorTimestamp() {
// return authorTimestamp;
// }
//
// public String getMessage() {
// return message;
// }
//
// public List<MinimalCommit> getParentsIds() {
// return parentsIds;
// }
//
// @Override
// public String toString() {
// return "Commit{" +
// "id='" + id + '\'' +
// ", displayId='" + displayId + '\'' +
// ", authorName='" + authorName + '\'' +
// ", authorEmail='" + authorEmail + '\'' +
// ", authorTimestamp=" + authorTimestamp +
// ", message='" + message + '\'' +
// ", parentsIds=" + parentsIds +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Commit changeSet = (Commit) o;
// return Objects.equals(authorTimestamp, changeSet.authorTimestamp) &&
// Objects.equals(id, changeSet.id) &&
// Objects.equals(displayId, changeSet.displayId) &&
// Objects.equals(authorName, changeSet.authorName) &&
// Objects.equals(authorEmail, changeSet.authorEmail) &&
// Objects.equals(message, changeSet.message) &&
// Objects.equals(parentsIds, changeSet.parentsIds);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(id, displayId, authorName, authorEmail, authorTimestamp, message, parentsIds);
// }
//
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static <T> Function<JsonElement, List<T>> listParser(Function<JsonElement, T> elementParser) {
// return new ListParser<>(elementParser);
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, MinimalCommit> minimalCommitParser() {
// return MINIMAL_COMMIT_PARSER;
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/CommitParser.java
import com.ccreanga.bitbucket.rest.client.model.Commit;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.listParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.minimalCommitParser;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class CommitParser implements Function<JsonElement, Commit> {
@Override
public Commit apply(JsonElement jsonElement) {
if (jsonElement == null || !jsonElement.isJsonObject()) {
return null;
}
JsonObject json = jsonElement.getAsJsonObject();
return new Commit(
json.get("id").getAsString(),
json.get("displayId").getAsString(),
json.get("author").getAsJsonObject().get("name").getAsString(),
json.get("author").getAsJsonObject().get("emailAddress").getAsString(),
json.get("authorTimestamp").getAsLong(),
json.get("message").getAsString(), | listParser(minimalCommitParser()).apply(json.get("parents")) |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/CommitParser.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Commit.java
// public class Commit implements Serializable {
//
// private String id;
// private String displayId;
// private String authorName;
// private String authorEmail;
// private long authorTimestamp;
// private String message;
// private List<MinimalCommit> parentsIds;
//
// private Commit() {
// }
//
// public Commit(String id, String displayId, String authorName, String authorEmail, long authorTimestamp, String message, List<MinimalCommit> parentsIds) {
// this.id = id;
// this.displayId = displayId;
// this.authorName = authorName;
// this.authorEmail = authorEmail;
// this.authorTimestamp = authorTimestamp;
// this.message = message;
// this.parentsIds = ImmutableList.copyOf(parentsIds);
// }
//
// public String getId() {
// return id;
// }
//
// public String getDisplayId() {
// return displayId;
// }
//
// public String getAuthorName() {
// return authorName;
// }
//
// public String getAuthorEmail() {
// return authorEmail;
// }
//
// public long getAuthorTimestamp() {
// return authorTimestamp;
// }
//
// public String getMessage() {
// return message;
// }
//
// public List<MinimalCommit> getParentsIds() {
// return parentsIds;
// }
//
// @Override
// public String toString() {
// return "Commit{" +
// "id='" + id + '\'' +
// ", displayId='" + displayId + '\'' +
// ", authorName='" + authorName + '\'' +
// ", authorEmail='" + authorEmail + '\'' +
// ", authorTimestamp=" + authorTimestamp +
// ", message='" + message + '\'' +
// ", parentsIds=" + parentsIds +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Commit changeSet = (Commit) o;
// return Objects.equals(authorTimestamp, changeSet.authorTimestamp) &&
// Objects.equals(id, changeSet.id) &&
// Objects.equals(displayId, changeSet.displayId) &&
// Objects.equals(authorName, changeSet.authorName) &&
// Objects.equals(authorEmail, changeSet.authorEmail) &&
// Objects.equals(message, changeSet.message) &&
// Objects.equals(parentsIds, changeSet.parentsIds);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(id, displayId, authorName, authorEmail, authorTimestamp, message, parentsIds);
// }
//
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static <T> Function<JsonElement, List<T>> listParser(Function<JsonElement, T> elementParser) {
// return new ListParser<>(elementParser);
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, MinimalCommit> minimalCommitParser() {
// return MINIMAL_COMMIT_PARSER;
// }
| import com.ccreanga.bitbucket.rest.client.model.Commit;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.listParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.minimalCommitParser; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class CommitParser implements Function<JsonElement, Commit> {
@Override
public Commit apply(JsonElement jsonElement) {
if (jsonElement == null || !jsonElement.isJsonObject()) {
return null;
}
JsonObject json = jsonElement.getAsJsonObject();
return new Commit(
json.get("id").getAsString(),
json.get("displayId").getAsString(),
json.get("author").getAsJsonObject().get("name").getAsString(),
json.get("author").getAsJsonObject().get("emailAddress").getAsString(),
json.get("authorTimestamp").getAsLong(),
json.get("message").getAsString(), | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Commit.java
// public class Commit implements Serializable {
//
// private String id;
// private String displayId;
// private String authorName;
// private String authorEmail;
// private long authorTimestamp;
// private String message;
// private List<MinimalCommit> parentsIds;
//
// private Commit() {
// }
//
// public Commit(String id, String displayId, String authorName, String authorEmail, long authorTimestamp, String message, List<MinimalCommit> parentsIds) {
// this.id = id;
// this.displayId = displayId;
// this.authorName = authorName;
// this.authorEmail = authorEmail;
// this.authorTimestamp = authorTimestamp;
// this.message = message;
// this.parentsIds = ImmutableList.copyOf(parentsIds);
// }
//
// public String getId() {
// return id;
// }
//
// public String getDisplayId() {
// return displayId;
// }
//
// public String getAuthorName() {
// return authorName;
// }
//
// public String getAuthorEmail() {
// return authorEmail;
// }
//
// public long getAuthorTimestamp() {
// return authorTimestamp;
// }
//
// public String getMessage() {
// return message;
// }
//
// public List<MinimalCommit> getParentsIds() {
// return parentsIds;
// }
//
// @Override
// public String toString() {
// return "Commit{" +
// "id='" + id + '\'' +
// ", displayId='" + displayId + '\'' +
// ", authorName='" + authorName + '\'' +
// ", authorEmail='" + authorEmail + '\'' +
// ", authorTimestamp=" + authorTimestamp +
// ", message='" + message + '\'' +
// ", parentsIds=" + parentsIds +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Commit changeSet = (Commit) o;
// return Objects.equals(authorTimestamp, changeSet.authorTimestamp) &&
// Objects.equals(id, changeSet.id) &&
// Objects.equals(displayId, changeSet.displayId) &&
// Objects.equals(authorName, changeSet.authorName) &&
// Objects.equals(authorEmail, changeSet.authorEmail) &&
// Objects.equals(message, changeSet.message) &&
// Objects.equals(parentsIds, changeSet.parentsIds);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(id, displayId, authorName, authorEmail, authorTimestamp, message, parentsIds);
// }
//
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static <T> Function<JsonElement, List<T>> listParser(Function<JsonElement, T> elementParser) {
// return new ListParser<>(elementParser);
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, MinimalCommit> minimalCommitParser() {
// return MINIMAL_COMMIT_PARSER;
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/CommitParser.java
import com.ccreanga.bitbucket.rest.client.model.Commit;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.listParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.minimalCommitParser;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class CommitParser implements Function<JsonElement, Commit> {
@Override
public Commit apply(JsonElement jsonElement) {
if (jsonElement == null || !jsonElement.isJsonObject()) {
return null;
}
JsonObject json = jsonElement.getAsJsonObject();
return new Commit(
json.get("id").getAsString(),
json.get("displayId").getAsString(),
json.get("author").getAsJsonObject().get("name").getAsString(),
json.get("author").getAsJsonObject().get("emailAddress").getAsString(),
json.get("authorTimestamp").getAsLong(),
json.get("message").getAsString(), | listParser(minimalCommitParser()).apply(json.get("parents")) |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/SshClient.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Page.java
// public class Page<T> implements Serializable {
// private int size;
// private int limit;
// private boolean lastPage;
// private int start;
// @Nullable
// private Integer nextPageStart;
// @Nonnull
// private List<T> values;
//
// private Page() {
// }
//
// public Page(int size, int limit, boolean lastPage, int start, @Nullable Integer nextPageStart, @Nonnull Iterable<T> values) {
// if ((!lastPage) && (nextPageStart==null))
// throw new IllegalArgumentException("nextPageStart should be not null if lastPage is false");
// this.size = size;
// this.limit = limit;
// this.lastPage = lastPage;
// this.values = ImmutableList.copyOf(values);
// this.start = start;
// this.nextPageStart = nextPageStart;
// }
//
// public int getSize() {
// return size;
// }
//
// public int getLimit() {
// return limit;
// }
//
// public boolean isLastPage() {
// return lastPage;
// }
//
// @Nonnull
// public List<T> getValues() {
// return values;
// }
//
// public int getStart() {
// return start;
// }
//
// @Nullable
// public Integer getNextPageStart() {
// return nextPageStart;
// }
//
// @Override
// public String toString() {
// return "Page{" +
// "size=" + size +
// ", limit=" + limit +
// ", lastPage=" + lastPage +
// ", start=" + start +
// ", nextPageStart=" + nextPageStart +
// ", values=" + values +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Page<?> page = (Page<?>) o;
// return java.util.Objects.equals(size, page.size) &&
// java.util.Objects.equals(limit, page.limit) &&
// java.util.Objects.equals(lastPage, page.lastPage) &&
// java.util.Objects.equals(start, page.start) &&
// java.util.Objects.equals(nextPageStart, page.nextPageStart) &&
// java.util.Objects.equals(values, page.values);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(size, limit, lastPage, start, nextPageStart, values);
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/RepositorySshKey.java
// public class RepositorySshKey extends SshKey {
// private Repository repository;
// private String permission;
//
//
// public RepositorySshKey(long id, String text, String label, Repository repository, String permission) {
// super(text, label, id);
// this.repository = repository;
// this.permission = permission;
// }
//
// /**
// * @return repository the key belongs to
// */
// public Repository getRepository() {
// return repository;
// }
//
// /**
// * @return permission on the repository for this ssh key
// */
// public String getPermission() {
// return permission;
// }
//
// @Override
// public String toString() {
// return "RepositorySshKey{" +
// "repository=" + repository +
// ", permission='" + permission + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// RepositorySshKey that = (RepositorySshKey) o;
// return java.util.Objects.equals(repository, that.repository) &&
// java.util.Objects.equals(permission, that.permission);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(repository, permission);
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/UserSshKey.java
// public class UserSshKey extends SshKey implements Serializable {
//
// public UserSshKey(long id, String text, String label) {
// super(text, label, id);
// }
//
//
// }
| import com.ccreanga.bitbucket.rest.client.model.Page;
import com.ccreanga.bitbucket.rest.client.model.RepositorySshKey;
import com.ccreanga.bitbucket.rest.client.model.UserSshKey; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client;
public interface SshClient {
Page<RepositorySshKey> getRepositoryKeys(String projectKey, String repositorySlug, Range range);
| // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Page.java
// public class Page<T> implements Serializable {
// private int size;
// private int limit;
// private boolean lastPage;
// private int start;
// @Nullable
// private Integer nextPageStart;
// @Nonnull
// private List<T> values;
//
// private Page() {
// }
//
// public Page(int size, int limit, boolean lastPage, int start, @Nullable Integer nextPageStart, @Nonnull Iterable<T> values) {
// if ((!lastPage) && (nextPageStart==null))
// throw new IllegalArgumentException("nextPageStart should be not null if lastPage is false");
// this.size = size;
// this.limit = limit;
// this.lastPage = lastPage;
// this.values = ImmutableList.copyOf(values);
// this.start = start;
// this.nextPageStart = nextPageStart;
// }
//
// public int getSize() {
// return size;
// }
//
// public int getLimit() {
// return limit;
// }
//
// public boolean isLastPage() {
// return lastPage;
// }
//
// @Nonnull
// public List<T> getValues() {
// return values;
// }
//
// public int getStart() {
// return start;
// }
//
// @Nullable
// public Integer getNextPageStart() {
// return nextPageStart;
// }
//
// @Override
// public String toString() {
// return "Page{" +
// "size=" + size +
// ", limit=" + limit +
// ", lastPage=" + lastPage +
// ", start=" + start +
// ", nextPageStart=" + nextPageStart +
// ", values=" + values +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Page<?> page = (Page<?>) o;
// return java.util.Objects.equals(size, page.size) &&
// java.util.Objects.equals(limit, page.limit) &&
// java.util.Objects.equals(lastPage, page.lastPage) &&
// java.util.Objects.equals(start, page.start) &&
// java.util.Objects.equals(nextPageStart, page.nextPageStart) &&
// java.util.Objects.equals(values, page.values);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(size, limit, lastPage, start, nextPageStart, values);
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/RepositorySshKey.java
// public class RepositorySshKey extends SshKey {
// private Repository repository;
// private String permission;
//
//
// public RepositorySshKey(long id, String text, String label, Repository repository, String permission) {
// super(text, label, id);
// this.repository = repository;
// this.permission = permission;
// }
//
// /**
// * @return repository the key belongs to
// */
// public Repository getRepository() {
// return repository;
// }
//
// /**
// * @return permission on the repository for this ssh key
// */
// public String getPermission() {
// return permission;
// }
//
// @Override
// public String toString() {
// return "RepositorySshKey{" +
// "repository=" + repository +
// ", permission='" + permission + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// RepositorySshKey that = (RepositorySshKey) o;
// return java.util.Objects.equals(repository, that.repository) &&
// java.util.Objects.equals(permission, that.permission);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(repository, permission);
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/UserSshKey.java
// public class UserSshKey extends SshKey implements Serializable {
//
// public UserSshKey(long id, String text, String label) {
// super(text, label, id);
// }
//
//
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/SshClient.java
import com.ccreanga.bitbucket.rest.client.model.Page;
import com.ccreanga.bitbucket.rest.client.model.RepositorySshKey;
import com.ccreanga.bitbucket.rest.client.model.UserSshKey;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client;
public interface SshClient {
Page<RepositorySshKey> getRepositoryKeys(String projectKey, String repositorySlug, Range range);
| Page<UserSshKey> getCurrentUserKeys(Range range); |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ProjectParser.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Project.java
// public class Project implements Serializable {
// private String key;
// private long id;
// private String name;
// @Nullable
// private String description;
// private boolean isPublic;
// private boolean isPersonal;
// private ProjectType type;
// private String selfUrl;
//
// private Project() {
// }
//
// public Project(String key, long id, String name, @Nullable String description, boolean isPublic, boolean isPersonal, ProjectType type, String selfUrl) {
// this.key = key;
// this.id = id;
// this.name = name;
// this.description = description;
// this.isPublic = isPublic;
// this.isPersonal = isPersonal;
// this.type = type;
// this.selfUrl = selfUrl;
// }
//
// public String getKey() {
// return key;
// }
//
// public long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public boolean isPublic() {
// return isPublic;
// }
//
// public boolean isPersonal() {
// return isPersonal;
// }
//
// /**
// * Retrieves the project's type. As of writing it may be NORMAL or PERSONAL
// *
// * @return the type for this project
// */
// public ProjectType getType() {
// return type;
// }
//
// public String getSelfUrl() {
// return selfUrl;
// }
//
// @Override
// public String toString() {
// return "Project{" +
// "key='" + key + '\'' +
// ", id=" + id +
// ", name='" + name + '\'' +
// ", description='" + description + '\'' +
// ", isPublic=" + isPublic +
// ", isPersonal=" + isPersonal +
// ", type='" + type + '\'' +
// ", selfUrl='" + selfUrl + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Project project = (Project) o;
// return java.util.Objects.equals(id, project.id) &&
// java.util.Objects.equals(isPublic, project.isPublic) &&
// java.util.Objects.equals(isPersonal, project.isPersonal) &&
// java.util.Objects.equals(key, project.key) &&
// java.util.Objects.equals(name, project.name) &&
// java.util.Objects.equals(description, project.description) &&
// java.util.Objects.equals(type, project.type) &&
// java.util.Objects.equals(selfUrl, project.selfUrl);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(key, id, name, description, isPublic, isPersonal, type, selfUrl);
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/ProjectType.java
// public enum ProjectType implements Serializable {
// NORMAL,PERSONAL
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ParserUtil.java
// public static boolean optionalJsonBoolean(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return false;
// return element.getAsBoolean();
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ParserUtil.java
// public static String optionalJsonString(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return null;
// return element.getAsString();
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, Link> linkParser() {
// return new LinkParser();
// }
| import com.ccreanga.bitbucket.rest.client.model.Project;
import java.util.function.Function;
import com.ccreanga.bitbucket.rest.client.model.ProjectType;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.ParserUtil.optionalJsonBoolean;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.ParserUtil.optionalJsonString;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.linkParser; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
class ProjectParser implements Function<JsonElement, Project> {
@Override
public Project apply(JsonElement jsonElement) {
JsonObject json = jsonElement.getAsJsonObject();
String selfUrl = null;
if (json.has("links")) { | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Project.java
// public class Project implements Serializable {
// private String key;
// private long id;
// private String name;
// @Nullable
// private String description;
// private boolean isPublic;
// private boolean isPersonal;
// private ProjectType type;
// private String selfUrl;
//
// private Project() {
// }
//
// public Project(String key, long id, String name, @Nullable String description, boolean isPublic, boolean isPersonal, ProjectType type, String selfUrl) {
// this.key = key;
// this.id = id;
// this.name = name;
// this.description = description;
// this.isPublic = isPublic;
// this.isPersonal = isPersonal;
// this.type = type;
// this.selfUrl = selfUrl;
// }
//
// public String getKey() {
// return key;
// }
//
// public long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public boolean isPublic() {
// return isPublic;
// }
//
// public boolean isPersonal() {
// return isPersonal;
// }
//
// /**
// * Retrieves the project's type. As of writing it may be NORMAL or PERSONAL
// *
// * @return the type for this project
// */
// public ProjectType getType() {
// return type;
// }
//
// public String getSelfUrl() {
// return selfUrl;
// }
//
// @Override
// public String toString() {
// return "Project{" +
// "key='" + key + '\'' +
// ", id=" + id +
// ", name='" + name + '\'' +
// ", description='" + description + '\'' +
// ", isPublic=" + isPublic +
// ", isPersonal=" + isPersonal +
// ", type='" + type + '\'' +
// ", selfUrl='" + selfUrl + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Project project = (Project) o;
// return java.util.Objects.equals(id, project.id) &&
// java.util.Objects.equals(isPublic, project.isPublic) &&
// java.util.Objects.equals(isPersonal, project.isPersonal) &&
// java.util.Objects.equals(key, project.key) &&
// java.util.Objects.equals(name, project.name) &&
// java.util.Objects.equals(description, project.description) &&
// java.util.Objects.equals(type, project.type) &&
// java.util.Objects.equals(selfUrl, project.selfUrl);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(key, id, name, description, isPublic, isPersonal, type, selfUrl);
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/ProjectType.java
// public enum ProjectType implements Serializable {
// NORMAL,PERSONAL
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ParserUtil.java
// public static boolean optionalJsonBoolean(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return false;
// return element.getAsBoolean();
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ParserUtil.java
// public static String optionalJsonString(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return null;
// return element.getAsString();
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, Link> linkParser() {
// return new LinkParser();
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ProjectParser.java
import com.ccreanga.bitbucket.rest.client.model.Project;
import java.util.function.Function;
import com.ccreanga.bitbucket.rest.client.model.ProjectType;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.ParserUtil.optionalJsonBoolean;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.ParserUtil.optionalJsonString;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.linkParser;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
class ProjectParser implements Function<JsonElement, Project> {
@Override
public Project apply(JsonElement jsonElement) {
JsonObject json = jsonElement.getAsJsonObject();
String selfUrl = null;
if (json.has("links")) { | selfUrl = linkParser().apply(json.getAsJsonObject("links").get("self").getAsJsonArray().get(0)).getHref(); |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ProjectParser.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Project.java
// public class Project implements Serializable {
// private String key;
// private long id;
// private String name;
// @Nullable
// private String description;
// private boolean isPublic;
// private boolean isPersonal;
// private ProjectType type;
// private String selfUrl;
//
// private Project() {
// }
//
// public Project(String key, long id, String name, @Nullable String description, boolean isPublic, boolean isPersonal, ProjectType type, String selfUrl) {
// this.key = key;
// this.id = id;
// this.name = name;
// this.description = description;
// this.isPublic = isPublic;
// this.isPersonal = isPersonal;
// this.type = type;
// this.selfUrl = selfUrl;
// }
//
// public String getKey() {
// return key;
// }
//
// public long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public boolean isPublic() {
// return isPublic;
// }
//
// public boolean isPersonal() {
// return isPersonal;
// }
//
// /**
// * Retrieves the project's type. As of writing it may be NORMAL or PERSONAL
// *
// * @return the type for this project
// */
// public ProjectType getType() {
// return type;
// }
//
// public String getSelfUrl() {
// return selfUrl;
// }
//
// @Override
// public String toString() {
// return "Project{" +
// "key='" + key + '\'' +
// ", id=" + id +
// ", name='" + name + '\'' +
// ", description='" + description + '\'' +
// ", isPublic=" + isPublic +
// ", isPersonal=" + isPersonal +
// ", type='" + type + '\'' +
// ", selfUrl='" + selfUrl + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Project project = (Project) o;
// return java.util.Objects.equals(id, project.id) &&
// java.util.Objects.equals(isPublic, project.isPublic) &&
// java.util.Objects.equals(isPersonal, project.isPersonal) &&
// java.util.Objects.equals(key, project.key) &&
// java.util.Objects.equals(name, project.name) &&
// java.util.Objects.equals(description, project.description) &&
// java.util.Objects.equals(type, project.type) &&
// java.util.Objects.equals(selfUrl, project.selfUrl);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(key, id, name, description, isPublic, isPersonal, type, selfUrl);
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/ProjectType.java
// public enum ProjectType implements Serializable {
// NORMAL,PERSONAL
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ParserUtil.java
// public static boolean optionalJsonBoolean(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return false;
// return element.getAsBoolean();
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ParserUtil.java
// public static String optionalJsonString(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return null;
// return element.getAsString();
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, Link> linkParser() {
// return new LinkParser();
// }
| import com.ccreanga.bitbucket.rest.client.model.Project;
import java.util.function.Function;
import com.ccreanga.bitbucket.rest.client.model.ProjectType;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.ParserUtil.optionalJsonBoolean;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.ParserUtil.optionalJsonString;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.linkParser; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
class ProjectParser implements Function<JsonElement, Project> {
@Override
public Project apply(JsonElement jsonElement) {
JsonObject json = jsonElement.getAsJsonObject();
String selfUrl = null;
if (json.has("links")) {
selfUrl = linkParser().apply(json.getAsJsonObject("links").get("self").getAsJsonArray().get(0)).getHref();
}
return new Project(
json.get("key").getAsString(),
json.get("id").getAsLong(),
json.get("name").getAsString(), | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Project.java
// public class Project implements Serializable {
// private String key;
// private long id;
// private String name;
// @Nullable
// private String description;
// private boolean isPublic;
// private boolean isPersonal;
// private ProjectType type;
// private String selfUrl;
//
// private Project() {
// }
//
// public Project(String key, long id, String name, @Nullable String description, boolean isPublic, boolean isPersonal, ProjectType type, String selfUrl) {
// this.key = key;
// this.id = id;
// this.name = name;
// this.description = description;
// this.isPublic = isPublic;
// this.isPersonal = isPersonal;
// this.type = type;
// this.selfUrl = selfUrl;
// }
//
// public String getKey() {
// return key;
// }
//
// public long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public boolean isPublic() {
// return isPublic;
// }
//
// public boolean isPersonal() {
// return isPersonal;
// }
//
// /**
// * Retrieves the project's type. As of writing it may be NORMAL or PERSONAL
// *
// * @return the type for this project
// */
// public ProjectType getType() {
// return type;
// }
//
// public String getSelfUrl() {
// return selfUrl;
// }
//
// @Override
// public String toString() {
// return "Project{" +
// "key='" + key + '\'' +
// ", id=" + id +
// ", name='" + name + '\'' +
// ", description='" + description + '\'' +
// ", isPublic=" + isPublic +
// ", isPersonal=" + isPersonal +
// ", type='" + type + '\'' +
// ", selfUrl='" + selfUrl + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Project project = (Project) o;
// return java.util.Objects.equals(id, project.id) &&
// java.util.Objects.equals(isPublic, project.isPublic) &&
// java.util.Objects.equals(isPersonal, project.isPersonal) &&
// java.util.Objects.equals(key, project.key) &&
// java.util.Objects.equals(name, project.name) &&
// java.util.Objects.equals(description, project.description) &&
// java.util.Objects.equals(type, project.type) &&
// java.util.Objects.equals(selfUrl, project.selfUrl);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(key, id, name, description, isPublic, isPersonal, type, selfUrl);
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/ProjectType.java
// public enum ProjectType implements Serializable {
// NORMAL,PERSONAL
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ParserUtil.java
// public static boolean optionalJsonBoolean(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return false;
// return element.getAsBoolean();
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ParserUtil.java
// public static String optionalJsonString(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return null;
// return element.getAsString();
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, Link> linkParser() {
// return new LinkParser();
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ProjectParser.java
import com.ccreanga.bitbucket.rest.client.model.Project;
import java.util.function.Function;
import com.ccreanga.bitbucket.rest.client.model.ProjectType;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.ParserUtil.optionalJsonBoolean;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.ParserUtil.optionalJsonString;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.linkParser;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
class ProjectParser implements Function<JsonElement, Project> {
@Override
public Project apply(JsonElement jsonElement) {
JsonObject json = jsonElement.getAsJsonObject();
String selfUrl = null;
if (json.has("links")) {
selfUrl = linkParser().apply(json.getAsJsonObject("links").get("self").getAsJsonArray().get(0)).getHref();
}
return new Project(
json.get("key").getAsString(),
json.get("id").getAsLong(),
json.get("name").getAsString(), | optionalJsonString(json, "description"), |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ProjectParser.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Project.java
// public class Project implements Serializable {
// private String key;
// private long id;
// private String name;
// @Nullable
// private String description;
// private boolean isPublic;
// private boolean isPersonal;
// private ProjectType type;
// private String selfUrl;
//
// private Project() {
// }
//
// public Project(String key, long id, String name, @Nullable String description, boolean isPublic, boolean isPersonal, ProjectType type, String selfUrl) {
// this.key = key;
// this.id = id;
// this.name = name;
// this.description = description;
// this.isPublic = isPublic;
// this.isPersonal = isPersonal;
// this.type = type;
// this.selfUrl = selfUrl;
// }
//
// public String getKey() {
// return key;
// }
//
// public long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public boolean isPublic() {
// return isPublic;
// }
//
// public boolean isPersonal() {
// return isPersonal;
// }
//
// /**
// * Retrieves the project's type. As of writing it may be NORMAL or PERSONAL
// *
// * @return the type for this project
// */
// public ProjectType getType() {
// return type;
// }
//
// public String getSelfUrl() {
// return selfUrl;
// }
//
// @Override
// public String toString() {
// return "Project{" +
// "key='" + key + '\'' +
// ", id=" + id +
// ", name='" + name + '\'' +
// ", description='" + description + '\'' +
// ", isPublic=" + isPublic +
// ", isPersonal=" + isPersonal +
// ", type='" + type + '\'' +
// ", selfUrl='" + selfUrl + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Project project = (Project) o;
// return java.util.Objects.equals(id, project.id) &&
// java.util.Objects.equals(isPublic, project.isPublic) &&
// java.util.Objects.equals(isPersonal, project.isPersonal) &&
// java.util.Objects.equals(key, project.key) &&
// java.util.Objects.equals(name, project.name) &&
// java.util.Objects.equals(description, project.description) &&
// java.util.Objects.equals(type, project.type) &&
// java.util.Objects.equals(selfUrl, project.selfUrl);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(key, id, name, description, isPublic, isPersonal, type, selfUrl);
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/ProjectType.java
// public enum ProjectType implements Serializable {
// NORMAL,PERSONAL
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ParserUtil.java
// public static boolean optionalJsonBoolean(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return false;
// return element.getAsBoolean();
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ParserUtil.java
// public static String optionalJsonString(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return null;
// return element.getAsString();
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, Link> linkParser() {
// return new LinkParser();
// }
| import com.ccreanga.bitbucket.rest.client.model.Project;
import java.util.function.Function;
import com.ccreanga.bitbucket.rest.client.model.ProjectType;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.ParserUtil.optionalJsonBoolean;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.ParserUtil.optionalJsonString;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.linkParser; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
class ProjectParser implements Function<JsonElement, Project> {
@Override
public Project apply(JsonElement jsonElement) {
JsonObject json = jsonElement.getAsJsonObject();
String selfUrl = null;
if (json.has("links")) {
selfUrl = linkParser().apply(json.getAsJsonObject("links").get("self").getAsJsonArray().get(0)).getHref();
}
return new Project(
json.get("key").getAsString(),
json.get("id").getAsLong(),
json.get("name").getAsString(),
optionalJsonString(json, "description"), | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Project.java
// public class Project implements Serializable {
// private String key;
// private long id;
// private String name;
// @Nullable
// private String description;
// private boolean isPublic;
// private boolean isPersonal;
// private ProjectType type;
// private String selfUrl;
//
// private Project() {
// }
//
// public Project(String key, long id, String name, @Nullable String description, boolean isPublic, boolean isPersonal, ProjectType type, String selfUrl) {
// this.key = key;
// this.id = id;
// this.name = name;
// this.description = description;
// this.isPublic = isPublic;
// this.isPersonal = isPersonal;
// this.type = type;
// this.selfUrl = selfUrl;
// }
//
// public String getKey() {
// return key;
// }
//
// public long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public boolean isPublic() {
// return isPublic;
// }
//
// public boolean isPersonal() {
// return isPersonal;
// }
//
// /**
// * Retrieves the project's type. As of writing it may be NORMAL or PERSONAL
// *
// * @return the type for this project
// */
// public ProjectType getType() {
// return type;
// }
//
// public String getSelfUrl() {
// return selfUrl;
// }
//
// @Override
// public String toString() {
// return "Project{" +
// "key='" + key + '\'' +
// ", id=" + id +
// ", name='" + name + '\'' +
// ", description='" + description + '\'' +
// ", isPublic=" + isPublic +
// ", isPersonal=" + isPersonal +
// ", type='" + type + '\'' +
// ", selfUrl='" + selfUrl + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Project project = (Project) o;
// return java.util.Objects.equals(id, project.id) &&
// java.util.Objects.equals(isPublic, project.isPublic) &&
// java.util.Objects.equals(isPersonal, project.isPersonal) &&
// java.util.Objects.equals(key, project.key) &&
// java.util.Objects.equals(name, project.name) &&
// java.util.Objects.equals(description, project.description) &&
// java.util.Objects.equals(type, project.type) &&
// java.util.Objects.equals(selfUrl, project.selfUrl);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(key, id, name, description, isPublic, isPersonal, type, selfUrl);
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/ProjectType.java
// public enum ProjectType implements Serializable {
// NORMAL,PERSONAL
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ParserUtil.java
// public static boolean optionalJsonBoolean(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return false;
// return element.getAsBoolean();
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ParserUtil.java
// public static String optionalJsonString(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return null;
// return element.getAsString();
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, Link> linkParser() {
// return new LinkParser();
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ProjectParser.java
import com.ccreanga.bitbucket.rest.client.model.Project;
import java.util.function.Function;
import com.ccreanga.bitbucket.rest.client.model.ProjectType;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.ParserUtil.optionalJsonBoolean;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.ParserUtil.optionalJsonString;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.linkParser;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
class ProjectParser implements Function<JsonElement, Project> {
@Override
public Project apply(JsonElement jsonElement) {
JsonObject json = jsonElement.getAsJsonObject();
String selfUrl = null;
if (json.has("links")) {
selfUrl = linkParser().apply(json.getAsJsonObject("links").get("self").getAsJsonArray().get(0)).getHref();
}
return new Project(
json.get("key").getAsString(),
json.get("id").getAsLong(),
json.get("name").getAsString(),
optionalJsonString(json, "description"), | optionalJsonBoolean(json, "public"), |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ProjectParser.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Project.java
// public class Project implements Serializable {
// private String key;
// private long id;
// private String name;
// @Nullable
// private String description;
// private boolean isPublic;
// private boolean isPersonal;
// private ProjectType type;
// private String selfUrl;
//
// private Project() {
// }
//
// public Project(String key, long id, String name, @Nullable String description, boolean isPublic, boolean isPersonal, ProjectType type, String selfUrl) {
// this.key = key;
// this.id = id;
// this.name = name;
// this.description = description;
// this.isPublic = isPublic;
// this.isPersonal = isPersonal;
// this.type = type;
// this.selfUrl = selfUrl;
// }
//
// public String getKey() {
// return key;
// }
//
// public long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public boolean isPublic() {
// return isPublic;
// }
//
// public boolean isPersonal() {
// return isPersonal;
// }
//
// /**
// * Retrieves the project's type. As of writing it may be NORMAL or PERSONAL
// *
// * @return the type for this project
// */
// public ProjectType getType() {
// return type;
// }
//
// public String getSelfUrl() {
// return selfUrl;
// }
//
// @Override
// public String toString() {
// return "Project{" +
// "key='" + key + '\'' +
// ", id=" + id +
// ", name='" + name + '\'' +
// ", description='" + description + '\'' +
// ", isPublic=" + isPublic +
// ", isPersonal=" + isPersonal +
// ", type='" + type + '\'' +
// ", selfUrl='" + selfUrl + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Project project = (Project) o;
// return java.util.Objects.equals(id, project.id) &&
// java.util.Objects.equals(isPublic, project.isPublic) &&
// java.util.Objects.equals(isPersonal, project.isPersonal) &&
// java.util.Objects.equals(key, project.key) &&
// java.util.Objects.equals(name, project.name) &&
// java.util.Objects.equals(description, project.description) &&
// java.util.Objects.equals(type, project.type) &&
// java.util.Objects.equals(selfUrl, project.selfUrl);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(key, id, name, description, isPublic, isPersonal, type, selfUrl);
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/ProjectType.java
// public enum ProjectType implements Serializable {
// NORMAL,PERSONAL
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ParserUtil.java
// public static boolean optionalJsonBoolean(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return false;
// return element.getAsBoolean();
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ParserUtil.java
// public static String optionalJsonString(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return null;
// return element.getAsString();
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, Link> linkParser() {
// return new LinkParser();
// }
| import com.ccreanga.bitbucket.rest.client.model.Project;
import java.util.function.Function;
import com.ccreanga.bitbucket.rest.client.model.ProjectType;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.ParserUtil.optionalJsonBoolean;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.ParserUtil.optionalJsonString;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.linkParser; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
class ProjectParser implements Function<JsonElement, Project> {
@Override
public Project apply(JsonElement jsonElement) {
JsonObject json = jsonElement.getAsJsonObject();
String selfUrl = null;
if (json.has("links")) {
selfUrl = linkParser().apply(json.getAsJsonObject("links").get("self").getAsJsonArray().get(0)).getHref();
}
return new Project(
json.get("key").getAsString(),
json.get("id").getAsLong(),
json.get("name").getAsString(),
optionalJsonString(json, "description"),
optionalJsonBoolean(json, "public"),
optionalJsonBoolean(json, "isPersonal"), | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Project.java
// public class Project implements Serializable {
// private String key;
// private long id;
// private String name;
// @Nullable
// private String description;
// private boolean isPublic;
// private boolean isPersonal;
// private ProjectType type;
// private String selfUrl;
//
// private Project() {
// }
//
// public Project(String key, long id, String name, @Nullable String description, boolean isPublic, boolean isPersonal, ProjectType type, String selfUrl) {
// this.key = key;
// this.id = id;
// this.name = name;
// this.description = description;
// this.isPublic = isPublic;
// this.isPersonal = isPersonal;
// this.type = type;
// this.selfUrl = selfUrl;
// }
//
// public String getKey() {
// return key;
// }
//
// public long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getDescription() {
// return description;
// }
//
// public boolean isPublic() {
// return isPublic;
// }
//
// public boolean isPersonal() {
// return isPersonal;
// }
//
// /**
// * Retrieves the project's type. As of writing it may be NORMAL or PERSONAL
// *
// * @return the type for this project
// */
// public ProjectType getType() {
// return type;
// }
//
// public String getSelfUrl() {
// return selfUrl;
// }
//
// @Override
// public String toString() {
// return "Project{" +
// "key='" + key + '\'' +
// ", id=" + id +
// ", name='" + name + '\'' +
// ", description='" + description + '\'' +
// ", isPublic=" + isPublic +
// ", isPersonal=" + isPersonal +
// ", type='" + type + '\'' +
// ", selfUrl='" + selfUrl + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Project project = (Project) o;
// return java.util.Objects.equals(id, project.id) &&
// java.util.Objects.equals(isPublic, project.isPublic) &&
// java.util.Objects.equals(isPersonal, project.isPersonal) &&
// java.util.Objects.equals(key, project.key) &&
// java.util.Objects.equals(name, project.name) &&
// java.util.Objects.equals(description, project.description) &&
// java.util.Objects.equals(type, project.type) &&
// java.util.Objects.equals(selfUrl, project.selfUrl);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(key, id, name, description, isPublic, isPersonal, type, selfUrl);
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/ProjectType.java
// public enum ProjectType implements Serializable {
// NORMAL,PERSONAL
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ParserUtil.java
// public static boolean optionalJsonBoolean(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return false;
// return element.getAsBoolean();
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ParserUtil.java
// public static String optionalJsonString(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return null;
// return element.getAsString();
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, Link> linkParser() {
// return new LinkParser();
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ProjectParser.java
import com.ccreanga.bitbucket.rest.client.model.Project;
import java.util.function.Function;
import com.ccreanga.bitbucket.rest.client.model.ProjectType;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.ParserUtil.optionalJsonBoolean;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.ParserUtil.optionalJsonString;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.linkParser;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
class ProjectParser implements Function<JsonElement, Project> {
@Override
public Project apply(JsonElement jsonElement) {
JsonObject json = jsonElement.getAsJsonObject();
String selfUrl = null;
if (json.has("links")) {
selfUrl = linkParser().apply(json.getAsJsonObject("links").get("self").getAsJsonArray().get(0)).getHref();
}
return new Project(
json.get("key").getAsString(),
json.get("id").getAsLong(),
json.get("name").getAsString(),
optionalJsonString(json, "description"),
optionalJsonBoolean(json, "public"),
optionalJsonBoolean(json, "isPersonal"), | ProjectType.valueOf(json.get("type").getAsString()), |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/activity/PullRequestApprovedActivity.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/User.java
// public class User implements Serializable {
//
// private long id;
// private String name;
// private String emailAddress;
// private String displayName;
// private boolean active;
// private String slug;
// private UserType type;
//
// private User() {
// }
//
// public User(long id, String name, String emailAddress, String displayName, boolean active, String slug, UserType type) {
// this.id = id;
// this.name = name;
// this.emailAddress = emailAddress;
// this.displayName = displayName;
// this.active = active;
// this.slug = slug;
// this.type = type;
// }
//
// public long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public boolean isActive() {
// return active;
// }
//
// public String getSlug() {
// return slug;
// }
//
// public UserType getType() {
// return type;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", emailAddress='" + emailAddress + '\'' +
// ", displayName='" + displayName + '\'' +
// ", active=" + active +
// ", slug='" + slug + '\'' +
// ", type='" + type + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// User user = (User) o;
// return java.util.Objects.equals(id, user.id) &&
// java.util.Objects.equals(active, user.active) &&
// java.util.Objects.equals(name, user.name) &&
// java.util.Objects.equals(emailAddress, user.emailAddress) &&
// java.util.Objects.equals(displayName, user.displayName) &&
// java.util.Objects.equals(slug, user.slug) &&
// java.util.Objects.equals(type, user.type);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(id, name, emailAddress, displayName, active, slug, type);
// }
// }
| import com.ccreanga.bitbucket.rest.client.model.User;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.model.pull.activity;
public class PullRequestApprovedActivity extends PullRequestActivity{
protected PullRequestApprovedActivity() {
}
| // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/User.java
// public class User implements Serializable {
//
// private long id;
// private String name;
// private String emailAddress;
// private String displayName;
// private boolean active;
// private String slug;
// private UserType type;
//
// private User() {
// }
//
// public User(long id, String name, String emailAddress, String displayName, boolean active, String slug, UserType type) {
// this.id = id;
// this.name = name;
// this.emailAddress = emailAddress;
// this.displayName = displayName;
// this.active = active;
// this.slug = slug;
// this.type = type;
// }
//
// public long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public boolean isActive() {
// return active;
// }
//
// public String getSlug() {
// return slug;
// }
//
// public UserType getType() {
// return type;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", emailAddress='" + emailAddress + '\'' +
// ", displayName='" + displayName + '\'' +
// ", active=" + active +
// ", slug='" + slug + '\'' +
// ", type='" + type + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// User user = (User) o;
// return java.util.Objects.equals(id, user.id) &&
// java.util.Objects.equals(active, user.active) &&
// java.util.Objects.equals(name, user.name) &&
// java.util.Objects.equals(emailAddress, user.emailAddress) &&
// java.util.Objects.equals(displayName, user.displayName) &&
// java.util.Objects.equals(slug, user.slug) &&
// java.util.Objects.equals(type, user.type);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(id, name, emailAddress, displayName, active, slug, type);
// }
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/activity/PullRequestApprovedActivity.java
import com.ccreanga.bitbucket.rest.client.model.User;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.model.pull.activity;
public class PullRequestApprovedActivity extends PullRequestActivity{
protected PullRequestApprovedActivity() {
}
| public PullRequestApprovedActivity(Long id, Date createdDate, User user, long pullRequestId) { |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/http/ResourceNotFoundException.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/dto/BitBucketError.java
// public class BitBucketError {
// private String message;
// private String context;
// private String exceptionName;
//
// public BitBucketError(String message, String context, String exceptionName) {
// this.context = context;
// this.message = message;
// this.exceptionName = exceptionName;
// }
//
// @Nullable
// public String getContext() {
// return context;
// }
//
// @Nullable
// public String getMessage() {
// return message;
// }
//
// @Nullable
// public String getExceptionName() {
// return exceptionName;
// }
//
// @Override
// public String toString() {
// return "BitBucketError{" +
// "message='" + message + '\'' +
// ", context='" + context + '\'' +
// ", exceptionName='" + exceptionName + '\'' +
// '}';
// }
// }
| import com.ccreanga.bitbucket.rest.client.http.dto.BitBucketError;
import java.util.Collections; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http;
class ResourceNotFoundException extends GenericException {
public ResourceNotFoundException(String message, int statusCode, String statusMessage) { | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/dto/BitBucketError.java
// public class BitBucketError {
// private String message;
// private String context;
// private String exceptionName;
//
// public BitBucketError(String message, String context, String exceptionName) {
// this.context = context;
// this.message = message;
// this.exceptionName = exceptionName;
// }
//
// @Nullable
// public String getContext() {
// return context;
// }
//
// @Nullable
// public String getMessage() {
// return message;
// }
//
// @Nullable
// public String getExceptionName() {
// return exceptionName;
// }
//
// @Override
// public String toString() {
// return "BitBucketError{" +
// "message='" + message + '\'' +
// ", context='" + context + '\'' +
// ", exceptionName='" + exceptionName + '\'' +
// '}';
// }
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/ResourceNotFoundException.java
import com.ccreanga.bitbucket.rest.client.http.dto.BitBucketError;
import java.util.Collections;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http;
class ResourceNotFoundException extends GenericException {
public ResourceNotFoundException(String message, int statusCode, String statusMessage) { | super(Collections.<BitBucketError>emptyList(),statusCode,message, statusMessage); |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/activity/PullRequestOpenedActivity.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/User.java
// public class User implements Serializable {
//
// private long id;
// private String name;
// private String emailAddress;
// private String displayName;
// private boolean active;
// private String slug;
// private UserType type;
//
// private User() {
// }
//
// public User(long id, String name, String emailAddress, String displayName, boolean active, String slug, UserType type) {
// this.id = id;
// this.name = name;
// this.emailAddress = emailAddress;
// this.displayName = displayName;
// this.active = active;
// this.slug = slug;
// this.type = type;
// }
//
// public long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public boolean isActive() {
// return active;
// }
//
// public String getSlug() {
// return slug;
// }
//
// public UserType getType() {
// return type;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", emailAddress='" + emailAddress + '\'' +
// ", displayName='" + displayName + '\'' +
// ", active=" + active +
// ", slug='" + slug + '\'' +
// ", type='" + type + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// User user = (User) o;
// return java.util.Objects.equals(id, user.id) &&
// java.util.Objects.equals(active, user.active) &&
// java.util.Objects.equals(name, user.name) &&
// java.util.Objects.equals(emailAddress, user.emailAddress) &&
// java.util.Objects.equals(displayName, user.displayName) &&
// java.util.Objects.equals(slug, user.slug) &&
// java.util.Objects.equals(type, user.type);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(id, name, emailAddress, displayName, active, slug, type);
// }
// }
| import com.ccreanga.bitbucket.rest.client.model.User;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.model.pull.activity;
public class PullRequestOpenedActivity extends PullRequestActivity{
protected PullRequestOpenedActivity() {
}
| // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/User.java
// public class User implements Serializable {
//
// private long id;
// private String name;
// private String emailAddress;
// private String displayName;
// private boolean active;
// private String slug;
// private UserType type;
//
// private User() {
// }
//
// public User(long id, String name, String emailAddress, String displayName, boolean active, String slug, UserType type) {
// this.id = id;
// this.name = name;
// this.emailAddress = emailAddress;
// this.displayName = displayName;
// this.active = active;
// this.slug = slug;
// this.type = type;
// }
//
// public long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public boolean isActive() {
// return active;
// }
//
// public String getSlug() {
// return slug;
// }
//
// public UserType getType() {
// return type;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", emailAddress='" + emailAddress + '\'' +
// ", displayName='" + displayName + '\'' +
// ", active=" + active +
// ", slug='" + slug + '\'' +
// ", type='" + type + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// User user = (User) o;
// return java.util.Objects.equals(id, user.id) &&
// java.util.Objects.equals(active, user.active) &&
// java.util.Objects.equals(name, user.name) &&
// java.util.Objects.equals(emailAddress, user.emailAddress) &&
// java.util.Objects.equals(displayName, user.displayName) &&
// java.util.Objects.equals(slug, user.slug) &&
// java.util.Objects.equals(type, user.type);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(id, name, emailAddress, displayName, active, slug, type);
// }
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/activity/PullRequestOpenedActivity.java
import com.ccreanga.bitbucket.rest.client.model.User;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.model.pull.activity;
public class PullRequestOpenedActivity extends PullRequestActivity{
protected PullRequestOpenedActivity() {
}
| public PullRequestOpenedActivity(Long id, Date createdDate, User user, long pullRequestId) { |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/activity/PullRequestUnapprovedActivity.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/User.java
// public class User implements Serializable {
//
// private long id;
// private String name;
// private String emailAddress;
// private String displayName;
// private boolean active;
// private String slug;
// private UserType type;
//
// private User() {
// }
//
// public User(long id, String name, String emailAddress, String displayName, boolean active, String slug, UserType type) {
// this.id = id;
// this.name = name;
// this.emailAddress = emailAddress;
// this.displayName = displayName;
// this.active = active;
// this.slug = slug;
// this.type = type;
// }
//
// public long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public boolean isActive() {
// return active;
// }
//
// public String getSlug() {
// return slug;
// }
//
// public UserType getType() {
// return type;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", emailAddress='" + emailAddress + '\'' +
// ", displayName='" + displayName + '\'' +
// ", active=" + active +
// ", slug='" + slug + '\'' +
// ", type='" + type + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// User user = (User) o;
// return java.util.Objects.equals(id, user.id) &&
// java.util.Objects.equals(active, user.active) &&
// java.util.Objects.equals(name, user.name) &&
// java.util.Objects.equals(emailAddress, user.emailAddress) &&
// java.util.Objects.equals(displayName, user.displayName) &&
// java.util.Objects.equals(slug, user.slug) &&
// java.util.Objects.equals(type, user.type);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(id, name, emailAddress, displayName, active, slug, type);
// }
// }
| import com.ccreanga.bitbucket.rest.client.model.User;
import java.util.Date;
import java.util.Objects; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.model.pull.activity;
public class PullRequestUnapprovedActivity extends PullRequestActivity{
protected Long id;
protected Date createdDate; | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/User.java
// public class User implements Serializable {
//
// private long id;
// private String name;
// private String emailAddress;
// private String displayName;
// private boolean active;
// private String slug;
// private UserType type;
//
// private User() {
// }
//
// public User(long id, String name, String emailAddress, String displayName, boolean active, String slug, UserType type) {
// this.id = id;
// this.name = name;
// this.emailAddress = emailAddress;
// this.displayName = displayName;
// this.active = active;
// this.slug = slug;
// this.type = type;
// }
//
// public long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public boolean isActive() {
// return active;
// }
//
// public String getSlug() {
// return slug;
// }
//
// public UserType getType() {
// return type;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", emailAddress='" + emailAddress + '\'' +
// ", displayName='" + displayName + '\'' +
// ", active=" + active +
// ", slug='" + slug + '\'' +
// ", type='" + type + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// User user = (User) o;
// return java.util.Objects.equals(id, user.id) &&
// java.util.Objects.equals(active, user.active) &&
// java.util.Objects.equals(name, user.name) &&
// java.util.Objects.equals(emailAddress, user.emailAddress) &&
// java.util.Objects.equals(displayName, user.displayName) &&
// java.util.Objects.equals(slug, user.slug) &&
// java.util.Objects.equals(type, user.type);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(id, name, emailAddress, displayName, active, slug, type);
// }
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/activity/PullRequestUnapprovedActivity.java
import com.ccreanga.bitbucket.rest.client.model.User;
import java.util.Date;
import java.util.Objects;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.model.pull.activity;
public class PullRequestUnapprovedActivity extends PullRequestActivity{
protected Long id;
protected Date createdDate; | protected User user; |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/activity/PullRequestReOpenedActivity.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/User.java
// public class User implements Serializable {
//
// private long id;
// private String name;
// private String emailAddress;
// private String displayName;
// private boolean active;
// private String slug;
// private UserType type;
//
// private User() {
// }
//
// public User(long id, String name, String emailAddress, String displayName, boolean active, String slug, UserType type) {
// this.id = id;
// this.name = name;
// this.emailAddress = emailAddress;
// this.displayName = displayName;
// this.active = active;
// this.slug = slug;
// this.type = type;
// }
//
// public long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public boolean isActive() {
// return active;
// }
//
// public String getSlug() {
// return slug;
// }
//
// public UserType getType() {
// return type;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", emailAddress='" + emailAddress + '\'' +
// ", displayName='" + displayName + '\'' +
// ", active=" + active +
// ", slug='" + slug + '\'' +
// ", type='" + type + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// User user = (User) o;
// return java.util.Objects.equals(id, user.id) &&
// java.util.Objects.equals(active, user.active) &&
// java.util.Objects.equals(name, user.name) &&
// java.util.Objects.equals(emailAddress, user.emailAddress) &&
// java.util.Objects.equals(displayName, user.displayName) &&
// java.util.Objects.equals(slug, user.slug) &&
// java.util.Objects.equals(type, user.type);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(id, name, emailAddress, displayName, active, slug, type);
// }
// }
| import com.ccreanga.bitbucket.rest.client.model.User;
import java.util.Date;
import java.util.Objects; | package com.ccreanga.bitbucket.rest.client.model.pull.activity;
public class PullRequestReOpenedActivity extends PullRequestActivity{
protected Long id;
protected Date createdDate; | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/User.java
// public class User implements Serializable {
//
// private long id;
// private String name;
// private String emailAddress;
// private String displayName;
// private boolean active;
// private String slug;
// private UserType type;
//
// private User() {
// }
//
// public User(long id, String name, String emailAddress, String displayName, boolean active, String slug, UserType type) {
// this.id = id;
// this.name = name;
// this.emailAddress = emailAddress;
// this.displayName = displayName;
// this.active = active;
// this.slug = slug;
// this.type = type;
// }
//
// public long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public boolean isActive() {
// return active;
// }
//
// public String getSlug() {
// return slug;
// }
//
// public UserType getType() {
// return type;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", emailAddress='" + emailAddress + '\'' +
// ", displayName='" + displayName + '\'' +
// ", active=" + active +
// ", slug='" + slug + '\'' +
// ", type='" + type + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// User user = (User) o;
// return java.util.Objects.equals(id, user.id) &&
// java.util.Objects.equals(active, user.active) &&
// java.util.Objects.equals(name, user.name) &&
// java.util.Objects.equals(emailAddress, user.emailAddress) &&
// java.util.Objects.equals(displayName, user.displayName) &&
// java.util.Objects.equals(slug, user.slug) &&
// java.util.Objects.equals(type, user.type);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(id, name, emailAddress, displayName, active, slug, type);
// }
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/activity/PullRequestReOpenedActivity.java
import com.ccreanga.bitbucket.rest.client.model.User;
import java.util.Date;
import java.util.Objects;
package com.ccreanga.bitbucket.rest.client.model.pull.activity;
public class PullRequestReOpenedActivity extends PullRequestActivity{
protected Long id;
protected Date createdDate; | protected User user; |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/PullRequestParticipantParser.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/User.java
// public class User implements Serializable {
//
// private long id;
// private String name;
// private String emailAddress;
// private String displayName;
// private boolean active;
// private String slug;
// private UserType type;
//
// private User() {
// }
//
// public User(long id, String name, String emailAddress, String displayName, boolean active, String slug, UserType type) {
// this.id = id;
// this.name = name;
// this.emailAddress = emailAddress;
// this.displayName = displayName;
// this.active = active;
// this.slug = slug;
// this.type = type;
// }
//
// public long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public boolean isActive() {
// return active;
// }
//
// public String getSlug() {
// return slug;
// }
//
// public UserType getType() {
// return type;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", emailAddress='" + emailAddress + '\'' +
// ", displayName='" + displayName + '\'' +
// ", active=" + active +
// ", slug='" + slug + '\'' +
// ", type='" + type + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// User user = (User) o;
// return java.util.Objects.equals(id, user.id) &&
// java.util.Objects.equals(active, user.active) &&
// java.util.Objects.equals(name, user.name) &&
// java.util.Objects.equals(emailAddress, user.emailAddress) &&
// java.util.Objects.equals(displayName, user.displayName) &&
// java.util.Objects.equals(slug, user.slug) &&
// java.util.Objects.equals(type, user.type);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(id, name, emailAddress, displayName, active, slug, type);
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/PullRequestParticipant.java
// public class PullRequestParticipant implements Serializable {
//
// private User user;
// private PullRequestRole role;
// private boolean approved;
//
// private PullRequestParticipant() {
// }
//
// public PullRequestParticipant(User user, PullRequestRole role, boolean approved) {
// this.user = user;
// this.role = role;
// this.approved = approved;
// }
//
// public User getUser() {
// return user;
// }
//
// public PullRequestRole getRole() {
// return role;
// }
//
// public boolean isApproved() {
// return approved;
// }
//
// @Override
// public String toString() {
// return "PullRequestParticipant{" +
// "user=" + user +
// ", role='" + role + '\'' +
// ", approved=" + approved +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// PullRequestParticipant that = (PullRequestParticipant) o;
// return java.util.Objects.equals(approved, that.approved) &&
// java.util.Objects.equals(user, that.user) &&
// java.util.Objects.equals(role, that.role);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(user, role, approved);
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/PullRequestRole.java
// public enum PullRequestRole implements Serializable {
// AUTHOR, REVIEWER, PARTICIPANT
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, User> userParser() {
// return USER_PARSER;
// }
| import com.ccreanga.bitbucket.rest.client.model.User;
import com.ccreanga.bitbucket.rest.client.model.pull.PullRequestParticipant;
import com.ccreanga.bitbucket.rest.client.model.pull.PullRequestRole;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.userParser; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class PullRequestParticipantParser implements Function<JsonElement, PullRequestParticipant> {
@Override
public PullRequestParticipant apply(JsonElement jsonElement) {
JsonObject jsonObject = jsonElement.getAsJsonObject(); | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/User.java
// public class User implements Serializable {
//
// private long id;
// private String name;
// private String emailAddress;
// private String displayName;
// private boolean active;
// private String slug;
// private UserType type;
//
// private User() {
// }
//
// public User(long id, String name, String emailAddress, String displayName, boolean active, String slug, UserType type) {
// this.id = id;
// this.name = name;
// this.emailAddress = emailAddress;
// this.displayName = displayName;
// this.active = active;
// this.slug = slug;
// this.type = type;
// }
//
// public long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public boolean isActive() {
// return active;
// }
//
// public String getSlug() {
// return slug;
// }
//
// public UserType getType() {
// return type;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", emailAddress='" + emailAddress + '\'' +
// ", displayName='" + displayName + '\'' +
// ", active=" + active +
// ", slug='" + slug + '\'' +
// ", type='" + type + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// User user = (User) o;
// return java.util.Objects.equals(id, user.id) &&
// java.util.Objects.equals(active, user.active) &&
// java.util.Objects.equals(name, user.name) &&
// java.util.Objects.equals(emailAddress, user.emailAddress) &&
// java.util.Objects.equals(displayName, user.displayName) &&
// java.util.Objects.equals(slug, user.slug) &&
// java.util.Objects.equals(type, user.type);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(id, name, emailAddress, displayName, active, slug, type);
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/PullRequestParticipant.java
// public class PullRequestParticipant implements Serializable {
//
// private User user;
// private PullRequestRole role;
// private boolean approved;
//
// private PullRequestParticipant() {
// }
//
// public PullRequestParticipant(User user, PullRequestRole role, boolean approved) {
// this.user = user;
// this.role = role;
// this.approved = approved;
// }
//
// public User getUser() {
// return user;
// }
//
// public PullRequestRole getRole() {
// return role;
// }
//
// public boolean isApproved() {
// return approved;
// }
//
// @Override
// public String toString() {
// return "PullRequestParticipant{" +
// "user=" + user +
// ", role='" + role + '\'' +
// ", approved=" + approved +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// PullRequestParticipant that = (PullRequestParticipant) o;
// return java.util.Objects.equals(approved, that.approved) &&
// java.util.Objects.equals(user, that.user) &&
// java.util.Objects.equals(role, that.role);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(user, role, approved);
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/PullRequestRole.java
// public enum PullRequestRole implements Serializable {
// AUTHOR, REVIEWER, PARTICIPANT
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, User> userParser() {
// return USER_PARSER;
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/PullRequestParticipantParser.java
import com.ccreanga.bitbucket.rest.client.model.User;
import com.ccreanga.bitbucket.rest.client.model.pull.PullRequestParticipant;
import com.ccreanga.bitbucket.rest.client.model.pull.PullRequestRole;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.userParser;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class PullRequestParticipantParser implements Function<JsonElement, PullRequestParticipant> {
@Override
public PullRequestParticipant apply(JsonElement jsonElement) {
JsonObject jsonObject = jsonElement.getAsJsonObject(); | User user = userParser().apply(jsonObject.getAsJsonObject("user")); |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/PullRequestParticipantParser.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/User.java
// public class User implements Serializable {
//
// private long id;
// private String name;
// private String emailAddress;
// private String displayName;
// private boolean active;
// private String slug;
// private UserType type;
//
// private User() {
// }
//
// public User(long id, String name, String emailAddress, String displayName, boolean active, String slug, UserType type) {
// this.id = id;
// this.name = name;
// this.emailAddress = emailAddress;
// this.displayName = displayName;
// this.active = active;
// this.slug = slug;
// this.type = type;
// }
//
// public long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public boolean isActive() {
// return active;
// }
//
// public String getSlug() {
// return slug;
// }
//
// public UserType getType() {
// return type;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", emailAddress='" + emailAddress + '\'' +
// ", displayName='" + displayName + '\'' +
// ", active=" + active +
// ", slug='" + slug + '\'' +
// ", type='" + type + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// User user = (User) o;
// return java.util.Objects.equals(id, user.id) &&
// java.util.Objects.equals(active, user.active) &&
// java.util.Objects.equals(name, user.name) &&
// java.util.Objects.equals(emailAddress, user.emailAddress) &&
// java.util.Objects.equals(displayName, user.displayName) &&
// java.util.Objects.equals(slug, user.slug) &&
// java.util.Objects.equals(type, user.type);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(id, name, emailAddress, displayName, active, slug, type);
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/PullRequestParticipant.java
// public class PullRequestParticipant implements Serializable {
//
// private User user;
// private PullRequestRole role;
// private boolean approved;
//
// private PullRequestParticipant() {
// }
//
// public PullRequestParticipant(User user, PullRequestRole role, boolean approved) {
// this.user = user;
// this.role = role;
// this.approved = approved;
// }
//
// public User getUser() {
// return user;
// }
//
// public PullRequestRole getRole() {
// return role;
// }
//
// public boolean isApproved() {
// return approved;
// }
//
// @Override
// public String toString() {
// return "PullRequestParticipant{" +
// "user=" + user +
// ", role='" + role + '\'' +
// ", approved=" + approved +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// PullRequestParticipant that = (PullRequestParticipant) o;
// return java.util.Objects.equals(approved, that.approved) &&
// java.util.Objects.equals(user, that.user) &&
// java.util.Objects.equals(role, that.role);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(user, role, approved);
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/PullRequestRole.java
// public enum PullRequestRole implements Serializable {
// AUTHOR, REVIEWER, PARTICIPANT
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, User> userParser() {
// return USER_PARSER;
// }
| import com.ccreanga.bitbucket.rest.client.model.User;
import com.ccreanga.bitbucket.rest.client.model.pull.PullRequestParticipant;
import com.ccreanga.bitbucket.rest.client.model.pull.PullRequestRole;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.userParser; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class PullRequestParticipantParser implements Function<JsonElement, PullRequestParticipant> {
@Override
public PullRequestParticipant apply(JsonElement jsonElement) {
JsonObject jsonObject = jsonElement.getAsJsonObject(); | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/User.java
// public class User implements Serializable {
//
// private long id;
// private String name;
// private String emailAddress;
// private String displayName;
// private boolean active;
// private String slug;
// private UserType type;
//
// private User() {
// }
//
// public User(long id, String name, String emailAddress, String displayName, boolean active, String slug, UserType type) {
// this.id = id;
// this.name = name;
// this.emailAddress = emailAddress;
// this.displayName = displayName;
// this.active = active;
// this.slug = slug;
// this.type = type;
// }
//
// public long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public boolean isActive() {
// return active;
// }
//
// public String getSlug() {
// return slug;
// }
//
// public UserType getType() {
// return type;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", emailAddress='" + emailAddress + '\'' +
// ", displayName='" + displayName + '\'' +
// ", active=" + active +
// ", slug='" + slug + '\'' +
// ", type='" + type + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// User user = (User) o;
// return java.util.Objects.equals(id, user.id) &&
// java.util.Objects.equals(active, user.active) &&
// java.util.Objects.equals(name, user.name) &&
// java.util.Objects.equals(emailAddress, user.emailAddress) &&
// java.util.Objects.equals(displayName, user.displayName) &&
// java.util.Objects.equals(slug, user.slug) &&
// java.util.Objects.equals(type, user.type);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(id, name, emailAddress, displayName, active, slug, type);
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/PullRequestParticipant.java
// public class PullRequestParticipant implements Serializable {
//
// private User user;
// private PullRequestRole role;
// private boolean approved;
//
// private PullRequestParticipant() {
// }
//
// public PullRequestParticipant(User user, PullRequestRole role, boolean approved) {
// this.user = user;
// this.role = role;
// this.approved = approved;
// }
//
// public User getUser() {
// return user;
// }
//
// public PullRequestRole getRole() {
// return role;
// }
//
// public boolean isApproved() {
// return approved;
// }
//
// @Override
// public String toString() {
// return "PullRequestParticipant{" +
// "user=" + user +
// ", role='" + role + '\'' +
// ", approved=" + approved +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// PullRequestParticipant that = (PullRequestParticipant) o;
// return java.util.Objects.equals(approved, that.approved) &&
// java.util.Objects.equals(user, that.user) &&
// java.util.Objects.equals(role, that.role);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(user, role, approved);
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/PullRequestRole.java
// public enum PullRequestRole implements Serializable {
// AUTHOR, REVIEWER, PARTICIPANT
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, User> userParser() {
// return USER_PARSER;
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/PullRequestParticipantParser.java
import com.ccreanga.bitbucket.rest.client.model.User;
import com.ccreanga.bitbucket.rest.client.model.pull.PullRequestParticipant;
import com.ccreanga.bitbucket.rest.client.model.pull.PullRequestRole;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.userParser;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class PullRequestParticipantParser implements Function<JsonElement, PullRequestParticipant> {
@Override
public PullRequestParticipant apply(JsonElement jsonElement) {
JsonObject jsonObject = jsonElement.getAsJsonObject(); | User user = userParser().apply(jsonObject.getAsJsonObject("user")); |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/PullRequestParticipantParser.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/User.java
// public class User implements Serializable {
//
// private long id;
// private String name;
// private String emailAddress;
// private String displayName;
// private boolean active;
// private String slug;
// private UserType type;
//
// private User() {
// }
//
// public User(long id, String name, String emailAddress, String displayName, boolean active, String slug, UserType type) {
// this.id = id;
// this.name = name;
// this.emailAddress = emailAddress;
// this.displayName = displayName;
// this.active = active;
// this.slug = slug;
// this.type = type;
// }
//
// public long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public boolean isActive() {
// return active;
// }
//
// public String getSlug() {
// return slug;
// }
//
// public UserType getType() {
// return type;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", emailAddress='" + emailAddress + '\'' +
// ", displayName='" + displayName + '\'' +
// ", active=" + active +
// ", slug='" + slug + '\'' +
// ", type='" + type + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// User user = (User) o;
// return java.util.Objects.equals(id, user.id) &&
// java.util.Objects.equals(active, user.active) &&
// java.util.Objects.equals(name, user.name) &&
// java.util.Objects.equals(emailAddress, user.emailAddress) &&
// java.util.Objects.equals(displayName, user.displayName) &&
// java.util.Objects.equals(slug, user.slug) &&
// java.util.Objects.equals(type, user.type);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(id, name, emailAddress, displayName, active, slug, type);
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/PullRequestParticipant.java
// public class PullRequestParticipant implements Serializable {
//
// private User user;
// private PullRequestRole role;
// private boolean approved;
//
// private PullRequestParticipant() {
// }
//
// public PullRequestParticipant(User user, PullRequestRole role, boolean approved) {
// this.user = user;
// this.role = role;
// this.approved = approved;
// }
//
// public User getUser() {
// return user;
// }
//
// public PullRequestRole getRole() {
// return role;
// }
//
// public boolean isApproved() {
// return approved;
// }
//
// @Override
// public String toString() {
// return "PullRequestParticipant{" +
// "user=" + user +
// ", role='" + role + '\'' +
// ", approved=" + approved +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// PullRequestParticipant that = (PullRequestParticipant) o;
// return java.util.Objects.equals(approved, that.approved) &&
// java.util.Objects.equals(user, that.user) &&
// java.util.Objects.equals(role, that.role);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(user, role, approved);
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/PullRequestRole.java
// public enum PullRequestRole implements Serializable {
// AUTHOR, REVIEWER, PARTICIPANT
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, User> userParser() {
// return USER_PARSER;
// }
| import com.ccreanga.bitbucket.rest.client.model.User;
import com.ccreanga.bitbucket.rest.client.model.pull.PullRequestParticipant;
import com.ccreanga.bitbucket.rest.client.model.pull.PullRequestRole;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.userParser; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class PullRequestParticipantParser implements Function<JsonElement, PullRequestParticipant> {
@Override
public PullRequestParticipant apply(JsonElement jsonElement) {
JsonObject jsonObject = jsonElement.getAsJsonObject();
User user = userParser().apply(jsonObject.getAsJsonObject("user"));
return new PullRequestParticipant(
user, | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/User.java
// public class User implements Serializable {
//
// private long id;
// private String name;
// private String emailAddress;
// private String displayName;
// private boolean active;
// private String slug;
// private UserType type;
//
// private User() {
// }
//
// public User(long id, String name, String emailAddress, String displayName, boolean active, String slug, UserType type) {
// this.id = id;
// this.name = name;
// this.emailAddress = emailAddress;
// this.displayName = displayName;
// this.active = active;
// this.slug = slug;
// this.type = type;
// }
//
// public long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public boolean isActive() {
// return active;
// }
//
// public String getSlug() {
// return slug;
// }
//
// public UserType getType() {
// return type;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", emailAddress='" + emailAddress + '\'' +
// ", displayName='" + displayName + '\'' +
// ", active=" + active +
// ", slug='" + slug + '\'' +
// ", type='" + type + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// User user = (User) o;
// return java.util.Objects.equals(id, user.id) &&
// java.util.Objects.equals(active, user.active) &&
// java.util.Objects.equals(name, user.name) &&
// java.util.Objects.equals(emailAddress, user.emailAddress) &&
// java.util.Objects.equals(displayName, user.displayName) &&
// java.util.Objects.equals(slug, user.slug) &&
// java.util.Objects.equals(type, user.type);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(id, name, emailAddress, displayName, active, slug, type);
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/PullRequestParticipant.java
// public class PullRequestParticipant implements Serializable {
//
// private User user;
// private PullRequestRole role;
// private boolean approved;
//
// private PullRequestParticipant() {
// }
//
// public PullRequestParticipant(User user, PullRequestRole role, boolean approved) {
// this.user = user;
// this.role = role;
// this.approved = approved;
// }
//
// public User getUser() {
// return user;
// }
//
// public PullRequestRole getRole() {
// return role;
// }
//
// public boolean isApproved() {
// return approved;
// }
//
// @Override
// public String toString() {
// return "PullRequestParticipant{" +
// "user=" + user +
// ", role='" + role + '\'' +
// ", approved=" + approved +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// PullRequestParticipant that = (PullRequestParticipant) o;
// return java.util.Objects.equals(approved, that.approved) &&
// java.util.Objects.equals(user, that.user) &&
// java.util.Objects.equals(role, that.role);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(user, role, approved);
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/PullRequestRole.java
// public enum PullRequestRole implements Serializable {
// AUTHOR, REVIEWER, PARTICIPANT
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, User> userParser() {
// return USER_PARSER;
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/PullRequestParticipantParser.java
import com.ccreanga.bitbucket.rest.client.model.User;
import com.ccreanga.bitbucket.rest.client.model.pull.PullRequestParticipant;
import com.ccreanga.bitbucket.rest.client.model.pull.PullRequestRole;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.userParser;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class PullRequestParticipantParser implements Function<JsonElement, PullRequestParticipant> {
@Override
public PullRequestParticipant apply(JsonElement jsonElement) {
JsonObject jsonObject = jsonElement.getAsJsonObject();
User user = userParser().apply(jsonObject.getAsJsonObject("user"));
return new PullRequestParticipant(
user, | PullRequestRole.valueOf(jsonObject.get("role").getAsString()), |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/DiffSegmentParser.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/diff/DiffSegment.java
// public class DiffSegment implements Serializable {
//
// @Nonnull
// private List<DiffLine> lines;
// @Nonnull
// private DiffSegmentType type;
// private boolean truncated;
//
// private DiffSegment() {
// }
//
// public DiffSegment(@Nonnull List<DiffLine> lines, @Nonnull DiffSegmentType type, boolean truncated) {
// this.lines = lines;
// this.type = type;
// this.truncated = truncated;
// }
//
// @Nonnull
// public List<DiffLine> getLines() {
// return lines;
// }
//
// @Nonnull
// public DiffSegmentType getType() {
// return type;
// }
//
// public boolean isTruncated() {
// return truncated;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// DiffSegment that = (DiffSegment) o;
// return Objects.equals(truncated, that.truncated) &&
// Objects.equals(lines, that.lines) &&
// Objects.equals(type, that.type);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(lines, type, truncated);
// }
//
// @Override
// public String toString() {
// return "DiffSegment{" +
// "lines=" + lines +
// ", type=" + type +
// ", truncated=" + truncated +
// '}';
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/diff/DiffSegmentType.java
// public enum DiffSegmentType implements Serializable {
//
// ADDED,CONTEXT,REMOVED
//
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, DiffLine> diffLineParser() {
// return DIFF_LINE_PARSER;
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static <T> Function<JsonElement, List<T>> listParser(Function<JsonElement, T> elementParser) {
// return new ListParser<>(elementParser);
// }
| import com.ccreanga.bitbucket.rest.client.model.diff.DiffSegment;
import com.ccreanga.bitbucket.rest.client.model.diff.DiffSegmentType;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.diffLineParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.listParser; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class DiffSegmentParser implements Function<JsonElement, DiffSegment> {
@Override
public DiffSegment apply(JsonElement jsonElement) {
if (jsonElement == null || !jsonElement.isJsonObject()) {
return null;
}
JsonObject json = jsonElement.getAsJsonObject();
return new DiffSegment( | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/diff/DiffSegment.java
// public class DiffSegment implements Serializable {
//
// @Nonnull
// private List<DiffLine> lines;
// @Nonnull
// private DiffSegmentType type;
// private boolean truncated;
//
// private DiffSegment() {
// }
//
// public DiffSegment(@Nonnull List<DiffLine> lines, @Nonnull DiffSegmentType type, boolean truncated) {
// this.lines = lines;
// this.type = type;
// this.truncated = truncated;
// }
//
// @Nonnull
// public List<DiffLine> getLines() {
// return lines;
// }
//
// @Nonnull
// public DiffSegmentType getType() {
// return type;
// }
//
// public boolean isTruncated() {
// return truncated;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// DiffSegment that = (DiffSegment) o;
// return Objects.equals(truncated, that.truncated) &&
// Objects.equals(lines, that.lines) &&
// Objects.equals(type, that.type);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(lines, type, truncated);
// }
//
// @Override
// public String toString() {
// return "DiffSegment{" +
// "lines=" + lines +
// ", type=" + type +
// ", truncated=" + truncated +
// '}';
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/diff/DiffSegmentType.java
// public enum DiffSegmentType implements Serializable {
//
// ADDED,CONTEXT,REMOVED
//
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, DiffLine> diffLineParser() {
// return DIFF_LINE_PARSER;
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static <T> Function<JsonElement, List<T>> listParser(Function<JsonElement, T> elementParser) {
// return new ListParser<>(elementParser);
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/DiffSegmentParser.java
import com.ccreanga.bitbucket.rest.client.model.diff.DiffSegment;
import com.ccreanga.bitbucket.rest.client.model.diff.DiffSegmentType;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.diffLineParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.listParser;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class DiffSegmentParser implements Function<JsonElement, DiffSegment> {
@Override
public DiffSegment apply(JsonElement jsonElement) {
if (jsonElement == null || !jsonElement.isJsonObject()) {
return null;
}
JsonObject json = jsonElement.getAsJsonObject();
return new DiffSegment( | listParser(diffLineParser()).apply(json.get("lines")), |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/DiffSegmentParser.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/diff/DiffSegment.java
// public class DiffSegment implements Serializable {
//
// @Nonnull
// private List<DiffLine> lines;
// @Nonnull
// private DiffSegmentType type;
// private boolean truncated;
//
// private DiffSegment() {
// }
//
// public DiffSegment(@Nonnull List<DiffLine> lines, @Nonnull DiffSegmentType type, boolean truncated) {
// this.lines = lines;
// this.type = type;
// this.truncated = truncated;
// }
//
// @Nonnull
// public List<DiffLine> getLines() {
// return lines;
// }
//
// @Nonnull
// public DiffSegmentType getType() {
// return type;
// }
//
// public boolean isTruncated() {
// return truncated;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// DiffSegment that = (DiffSegment) o;
// return Objects.equals(truncated, that.truncated) &&
// Objects.equals(lines, that.lines) &&
// Objects.equals(type, that.type);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(lines, type, truncated);
// }
//
// @Override
// public String toString() {
// return "DiffSegment{" +
// "lines=" + lines +
// ", type=" + type +
// ", truncated=" + truncated +
// '}';
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/diff/DiffSegmentType.java
// public enum DiffSegmentType implements Serializable {
//
// ADDED,CONTEXT,REMOVED
//
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, DiffLine> diffLineParser() {
// return DIFF_LINE_PARSER;
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static <T> Function<JsonElement, List<T>> listParser(Function<JsonElement, T> elementParser) {
// return new ListParser<>(elementParser);
// }
| import com.ccreanga.bitbucket.rest.client.model.diff.DiffSegment;
import com.ccreanga.bitbucket.rest.client.model.diff.DiffSegmentType;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.diffLineParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.listParser; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class DiffSegmentParser implements Function<JsonElement, DiffSegment> {
@Override
public DiffSegment apply(JsonElement jsonElement) {
if (jsonElement == null || !jsonElement.isJsonObject()) {
return null;
}
JsonObject json = jsonElement.getAsJsonObject();
return new DiffSegment( | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/diff/DiffSegment.java
// public class DiffSegment implements Serializable {
//
// @Nonnull
// private List<DiffLine> lines;
// @Nonnull
// private DiffSegmentType type;
// private boolean truncated;
//
// private DiffSegment() {
// }
//
// public DiffSegment(@Nonnull List<DiffLine> lines, @Nonnull DiffSegmentType type, boolean truncated) {
// this.lines = lines;
// this.type = type;
// this.truncated = truncated;
// }
//
// @Nonnull
// public List<DiffLine> getLines() {
// return lines;
// }
//
// @Nonnull
// public DiffSegmentType getType() {
// return type;
// }
//
// public boolean isTruncated() {
// return truncated;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// DiffSegment that = (DiffSegment) o;
// return Objects.equals(truncated, that.truncated) &&
// Objects.equals(lines, that.lines) &&
// Objects.equals(type, that.type);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(lines, type, truncated);
// }
//
// @Override
// public String toString() {
// return "DiffSegment{" +
// "lines=" + lines +
// ", type=" + type +
// ", truncated=" + truncated +
// '}';
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/diff/DiffSegmentType.java
// public enum DiffSegmentType implements Serializable {
//
// ADDED,CONTEXT,REMOVED
//
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, DiffLine> diffLineParser() {
// return DIFF_LINE_PARSER;
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static <T> Function<JsonElement, List<T>> listParser(Function<JsonElement, T> elementParser) {
// return new ListParser<>(elementParser);
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/DiffSegmentParser.java
import com.ccreanga.bitbucket.rest.client.model.diff.DiffSegment;
import com.ccreanga.bitbucket.rest.client.model.diff.DiffSegmentType;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.diffLineParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.listParser;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class DiffSegmentParser implements Function<JsonElement, DiffSegment> {
@Override
public DiffSegment apply(JsonElement jsonElement) {
if (jsonElement == null || !jsonElement.isJsonObject()) {
return null;
}
JsonObject json = jsonElement.getAsJsonObject();
return new DiffSegment( | listParser(diffLineParser()).apply(json.get("lines")), |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/DiffSegmentParser.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/diff/DiffSegment.java
// public class DiffSegment implements Serializable {
//
// @Nonnull
// private List<DiffLine> lines;
// @Nonnull
// private DiffSegmentType type;
// private boolean truncated;
//
// private DiffSegment() {
// }
//
// public DiffSegment(@Nonnull List<DiffLine> lines, @Nonnull DiffSegmentType type, boolean truncated) {
// this.lines = lines;
// this.type = type;
// this.truncated = truncated;
// }
//
// @Nonnull
// public List<DiffLine> getLines() {
// return lines;
// }
//
// @Nonnull
// public DiffSegmentType getType() {
// return type;
// }
//
// public boolean isTruncated() {
// return truncated;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// DiffSegment that = (DiffSegment) o;
// return Objects.equals(truncated, that.truncated) &&
// Objects.equals(lines, that.lines) &&
// Objects.equals(type, that.type);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(lines, type, truncated);
// }
//
// @Override
// public String toString() {
// return "DiffSegment{" +
// "lines=" + lines +
// ", type=" + type +
// ", truncated=" + truncated +
// '}';
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/diff/DiffSegmentType.java
// public enum DiffSegmentType implements Serializable {
//
// ADDED,CONTEXT,REMOVED
//
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, DiffLine> diffLineParser() {
// return DIFF_LINE_PARSER;
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static <T> Function<JsonElement, List<T>> listParser(Function<JsonElement, T> elementParser) {
// return new ListParser<>(elementParser);
// }
| import com.ccreanga.bitbucket.rest.client.model.diff.DiffSegment;
import com.ccreanga.bitbucket.rest.client.model.diff.DiffSegmentType;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.diffLineParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.listParser; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class DiffSegmentParser implements Function<JsonElement, DiffSegment> {
@Override
public DiffSegment apply(JsonElement jsonElement) {
if (jsonElement == null || !jsonElement.isJsonObject()) {
return null;
}
JsonObject json = jsonElement.getAsJsonObject();
return new DiffSegment(
listParser(diffLineParser()).apply(json.get("lines")), | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/diff/DiffSegment.java
// public class DiffSegment implements Serializable {
//
// @Nonnull
// private List<DiffLine> lines;
// @Nonnull
// private DiffSegmentType type;
// private boolean truncated;
//
// private DiffSegment() {
// }
//
// public DiffSegment(@Nonnull List<DiffLine> lines, @Nonnull DiffSegmentType type, boolean truncated) {
// this.lines = lines;
// this.type = type;
// this.truncated = truncated;
// }
//
// @Nonnull
// public List<DiffLine> getLines() {
// return lines;
// }
//
// @Nonnull
// public DiffSegmentType getType() {
// return type;
// }
//
// public boolean isTruncated() {
// return truncated;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// DiffSegment that = (DiffSegment) o;
// return Objects.equals(truncated, that.truncated) &&
// Objects.equals(lines, that.lines) &&
// Objects.equals(type, that.type);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(lines, type, truncated);
// }
//
// @Override
// public String toString() {
// return "DiffSegment{" +
// "lines=" + lines +
// ", type=" + type +
// ", truncated=" + truncated +
// '}';
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/diff/DiffSegmentType.java
// public enum DiffSegmentType implements Serializable {
//
// ADDED,CONTEXT,REMOVED
//
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, DiffLine> diffLineParser() {
// return DIFF_LINE_PARSER;
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static <T> Function<JsonElement, List<T>> listParser(Function<JsonElement, T> elementParser) {
// return new ListParser<>(elementParser);
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/DiffSegmentParser.java
import com.ccreanga.bitbucket.rest.client.model.diff.DiffSegment;
import com.ccreanga.bitbucket.rest.client.model.diff.DiffSegmentType;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.diffLineParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.listParser;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class DiffSegmentParser implements Function<JsonElement, DiffSegment> {
@Override
public DiffSegment apply(JsonElement jsonElement) {
if (jsonElement == null || !jsonElement.isJsonObject()) {
return null;
}
JsonObject json = jsonElement.getAsJsonObject();
return new DiffSegment(
listParser(diffLineParser()).apply(json.get("lines")), | DiffSegmentType.valueOf(json.get("type").getAsString()), |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/http/UnauthorizedException.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/dto/BitBucketError.java
// public class BitBucketError {
// private String message;
// private String context;
// private String exceptionName;
//
// public BitBucketError(String message, String context, String exceptionName) {
// this.context = context;
// this.message = message;
// this.exceptionName = exceptionName;
// }
//
// @Nullable
// public String getContext() {
// return context;
// }
//
// @Nullable
// public String getMessage() {
// return message;
// }
//
// @Nullable
// public String getExceptionName() {
// return exceptionName;
// }
//
// @Override
// public String toString() {
// return "BitBucketError{" +
// "message='" + message + '\'' +
// ", context='" + context + '\'' +
// ", exceptionName='" + exceptionName + '\'' +
// '}';
// }
// }
| import com.ccreanga.bitbucket.rest.client.http.dto.BitBucketError;
import java.util.Collections;
import java.util.List; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http;
class UnauthorizedException extends GenericException {
public UnauthorizedException(String message, int statusCode, String statusMessage) { | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/dto/BitBucketError.java
// public class BitBucketError {
// private String message;
// private String context;
// private String exceptionName;
//
// public BitBucketError(String message, String context, String exceptionName) {
// this.context = context;
// this.message = message;
// this.exceptionName = exceptionName;
// }
//
// @Nullable
// public String getContext() {
// return context;
// }
//
// @Nullable
// public String getMessage() {
// return message;
// }
//
// @Nullable
// public String getExceptionName() {
// return exceptionName;
// }
//
// @Override
// public String toString() {
// return "BitBucketError{" +
// "message='" + message + '\'' +
// ", context='" + context + '\'' +
// ", exceptionName='" + exceptionName + '\'' +
// '}';
// }
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/UnauthorizedException.java
import com.ccreanga.bitbucket.rest.client.http.dto.BitBucketError;
import java.util.Collections;
import java.util.List;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http;
class UnauthorizedException extends GenericException {
public UnauthorizedException(String message, int statusCode, String statusMessage) { | super(Collections.<BitBucketError>emptyList(),statusCode,message, statusMessage); |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/PageParser.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Page.java
// public class Page<T> implements Serializable {
// private int size;
// private int limit;
// private boolean lastPage;
// private int start;
// @Nullable
// private Integer nextPageStart;
// @Nonnull
// private List<T> values;
//
// private Page() {
// }
//
// public Page(int size, int limit, boolean lastPage, int start, @Nullable Integer nextPageStart, @Nonnull Iterable<T> values) {
// if ((!lastPage) && (nextPageStart==null))
// throw new IllegalArgumentException("nextPageStart should be not null if lastPage is false");
// this.size = size;
// this.limit = limit;
// this.lastPage = lastPage;
// this.values = ImmutableList.copyOf(values);
// this.start = start;
// this.nextPageStart = nextPageStart;
// }
//
// public int getSize() {
// return size;
// }
//
// public int getLimit() {
// return limit;
// }
//
// public boolean isLastPage() {
// return lastPage;
// }
//
// @Nonnull
// public List<T> getValues() {
// return values;
// }
//
// public int getStart() {
// return start;
// }
//
// @Nullable
// public Integer getNextPageStart() {
// return nextPageStart;
// }
//
// @Override
// public String toString() {
// return "Page{" +
// "size=" + size +
// ", limit=" + limit +
// ", lastPage=" + lastPage +
// ", start=" + start +
// ", nextPageStart=" + nextPageStart +
// ", values=" + values +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Page<?> page = (Page<?>) o;
// return java.util.Objects.equals(size, page.size) &&
// java.util.Objects.equals(limit, page.limit) &&
// java.util.Objects.equals(lastPage, page.lastPage) &&
// java.util.Objects.equals(start, page.start) &&
// java.util.Objects.equals(nextPageStart, page.nextPageStart) &&
// java.util.Objects.equals(values, page.values);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(size, limit, lastPage, start, nextPageStart, values);
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ParserUtil.java
// public static boolean optionalJsonBoolean(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return false;
// return element.getAsBoolean();
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ParserUtil.java
// public static long optionalJsonLong(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return -1;
// return element.getAsLong();
// }
| import com.ccreanga.bitbucket.rest.client.model.Page;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.List;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.ParserUtil.optionalJsonBoolean;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.ParserUtil.optionalJsonLong; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
class PageParser<T> implements Function<JsonElement, Page<T>> {
Function<JsonElement, T> valueParser;
public PageParser(Function<JsonElement, T> valueParser) {
this.valueParser = valueParser;
}
@Override
public Page<T> apply(JsonElement jsonElement) {
JsonObject json = jsonElement.getAsJsonObject();
List<T> values = Parsers.listParser(valueParser).apply(json.getAsJsonArray("values"));
return new Page<>(
json.get("size").getAsInt(),
json.get("limit").getAsInt(), | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Page.java
// public class Page<T> implements Serializable {
// private int size;
// private int limit;
// private boolean lastPage;
// private int start;
// @Nullable
// private Integer nextPageStart;
// @Nonnull
// private List<T> values;
//
// private Page() {
// }
//
// public Page(int size, int limit, boolean lastPage, int start, @Nullable Integer nextPageStart, @Nonnull Iterable<T> values) {
// if ((!lastPage) && (nextPageStart==null))
// throw new IllegalArgumentException("nextPageStart should be not null if lastPage is false");
// this.size = size;
// this.limit = limit;
// this.lastPage = lastPage;
// this.values = ImmutableList.copyOf(values);
// this.start = start;
// this.nextPageStart = nextPageStart;
// }
//
// public int getSize() {
// return size;
// }
//
// public int getLimit() {
// return limit;
// }
//
// public boolean isLastPage() {
// return lastPage;
// }
//
// @Nonnull
// public List<T> getValues() {
// return values;
// }
//
// public int getStart() {
// return start;
// }
//
// @Nullable
// public Integer getNextPageStart() {
// return nextPageStart;
// }
//
// @Override
// public String toString() {
// return "Page{" +
// "size=" + size +
// ", limit=" + limit +
// ", lastPage=" + lastPage +
// ", start=" + start +
// ", nextPageStart=" + nextPageStart +
// ", values=" + values +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Page<?> page = (Page<?>) o;
// return java.util.Objects.equals(size, page.size) &&
// java.util.Objects.equals(limit, page.limit) &&
// java.util.Objects.equals(lastPage, page.lastPage) &&
// java.util.Objects.equals(start, page.start) &&
// java.util.Objects.equals(nextPageStart, page.nextPageStart) &&
// java.util.Objects.equals(values, page.values);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(size, limit, lastPage, start, nextPageStart, values);
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ParserUtil.java
// public static boolean optionalJsonBoolean(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return false;
// return element.getAsBoolean();
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ParserUtil.java
// public static long optionalJsonLong(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return -1;
// return element.getAsLong();
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/PageParser.java
import com.ccreanga.bitbucket.rest.client.model.Page;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.List;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.ParserUtil.optionalJsonBoolean;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.ParserUtil.optionalJsonLong;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
class PageParser<T> implements Function<JsonElement, Page<T>> {
Function<JsonElement, T> valueParser;
public PageParser(Function<JsonElement, T> valueParser) {
this.valueParser = valueParser;
}
@Override
public Page<T> apply(JsonElement jsonElement) {
JsonObject json = jsonElement.getAsJsonObject();
List<T> values = Parsers.listParser(valueParser).apply(json.getAsJsonArray("values"));
return new Page<>(
json.get("size").getAsInt(),
json.get("limit").getAsInt(), | optionalJsonBoolean(json, "isLastPage"), |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/PageParser.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Page.java
// public class Page<T> implements Serializable {
// private int size;
// private int limit;
// private boolean lastPage;
// private int start;
// @Nullable
// private Integer nextPageStart;
// @Nonnull
// private List<T> values;
//
// private Page() {
// }
//
// public Page(int size, int limit, boolean lastPage, int start, @Nullable Integer nextPageStart, @Nonnull Iterable<T> values) {
// if ((!lastPage) && (nextPageStart==null))
// throw new IllegalArgumentException("nextPageStart should be not null if lastPage is false");
// this.size = size;
// this.limit = limit;
// this.lastPage = lastPage;
// this.values = ImmutableList.copyOf(values);
// this.start = start;
// this.nextPageStart = nextPageStart;
// }
//
// public int getSize() {
// return size;
// }
//
// public int getLimit() {
// return limit;
// }
//
// public boolean isLastPage() {
// return lastPage;
// }
//
// @Nonnull
// public List<T> getValues() {
// return values;
// }
//
// public int getStart() {
// return start;
// }
//
// @Nullable
// public Integer getNextPageStart() {
// return nextPageStart;
// }
//
// @Override
// public String toString() {
// return "Page{" +
// "size=" + size +
// ", limit=" + limit +
// ", lastPage=" + lastPage +
// ", start=" + start +
// ", nextPageStart=" + nextPageStart +
// ", values=" + values +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Page<?> page = (Page<?>) o;
// return java.util.Objects.equals(size, page.size) &&
// java.util.Objects.equals(limit, page.limit) &&
// java.util.Objects.equals(lastPage, page.lastPage) &&
// java.util.Objects.equals(start, page.start) &&
// java.util.Objects.equals(nextPageStart, page.nextPageStart) &&
// java.util.Objects.equals(values, page.values);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(size, limit, lastPage, start, nextPageStart, values);
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ParserUtil.java
// public static boolean optionalJsonBoolean(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return false;
// return element.getAsBoolean();
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ParserUtil.java
// public static long optionalJsonLong(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return -1;
// return element.getAsLong();
// }
| import com.ccreanga.bitbucket.rest.client.model.Page;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.List;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.ParserUtil.optionalJsonBoolean;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.ParserUtil.optionalJsonLong; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
class PageParser<T> implements Function<JsonElement, Page<T>> {
Function<JsonElement, T> valueParser;
public PageParser(Function<JsonElement, T> valueParser) {
this.valueParser = valueParser;
}
@Override
public Page<T> apply(JsonElement jsonElement) {
JsonObject json = jsonElement.getAsJsonObject();
List<T> values = Parsers.listParser(valueParser).apply(json.getAsJsonArray("values"));
return new Page<>(
json.get("size").getAsInt(),
json.get("limit").getAsInt(),
optionalJsonBoolean(json, "isLastPage"),
json.get("start").getAsInt(), | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Page.java
// public class Page<T> implements Serializable {
// private int size;
// private int limit;
// private boolean lastPage;
// private int start;
// @Nullable
// private Integer nextPageStart;
// @Nonnull
// private List<T> values;
//
// private Page() {
// }
//
// public Page(int size, int limit, boolean lastPage, int start, @Nullable Integer nextPageStart, @Nonnull Iterable<T> values) {
// if ((!lastPage) && (nextPageStart==null))
// throw new IllegalArgumentException("nextPageStart should be not null if lastPage is false");
// this.size = size;
// this.limit = limit;
// this.lastPage = lastPage;
// this.values = ImmutableList.copyOf(values);
// this.start = start;
// this.nextPageStart = nextPageStart;
// }
//
// public int getSize() {
// return size;
// }
//
// public int getLimit() {
// return limit;
// }
//
// public boolean isLastPage() {
// return lastPage;
// }
//
// @Nonnull
// public List<T> getValues() {
// return values;
// }
//
// public int getStart() {
// return start;
// }
//
// @Nullable
// public Integer getNextPageStart() {
// return nextPageStart;
// }
//
// @Override
// public String toString() {
// return "Page{" +
// "size=" + size +
// ", limit=" + limit +
// ", lastPage=" + lastPage +
// ", start=" + start +
// ", nextPageStart=" + nextPageStart +
// ", values=" + values +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Page<?> page = (Page<?>) o;
// return java.util.Objects.equals(size, page.size) &&
// java.util.Objects.equals(limit, page.limit) &&
// java.util.Objects.equals(lastPage, page.lastPage) &&
// java.util.Objects.equals(start, page.start) &&
// java.util.Objects.equals(nextPageStart, page.nextPageStart) &&
// java.util.Objects.equals(values, page.values);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(size, limit, lastPage, start, nextPageStart, values);
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ParserUtil.java
// public static boolean optionalJsonBoolean(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return false;
// return element.getAsBoolean();
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ParserUtil.java
// public static long optionalJsonLong(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return -1;
// return element.getAsLong();
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/PageParser.java
import com.ccreanga.bitbucket.rest.client.model.Page;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.List;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.ParserUtil.optionalJsonBoolean;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.ParserUtil.optionalJsonLong;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
class PageParser<T> implements Function<JsonElement, Page<T>> {
Function<JsonElement, T> valueParser;
public PageParser(Function<JsonElement, T> valueParser) {
this.valueParser = valueParser;
}
@Override
public Page<T> apply(JsonElement jsonElement) {
JsonObject json = jsonElement.getAsJsonObject();
List<T> values = Parsers.listParser(valueParser).apply(json.getAsJsonArray("values"));
return new Page<>(
json.get("size").getAsInt(),
json.get("limit").getAsInt(),
optionalJsonBoolean(json, "isLastPage"),
json.get("start").getAsInt(), | (int) optionalJsonLong(json, "nextPageStart"), |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/activity/PullRequestUpdatedActivity.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/User.java
// public class User implements Serializable {
//
// private long id;
// private String name;
// private String emailAddress;
// private String displayName;
// private boolean active;
// private String slug;
// private UserType type;
//
// private User() {
// }
//
// public User(long id, String name, String emailAddress, String displayName, boolean active, String slug, UserType type) {
// this.id = id;
// this.name = name;
// this.emailAddress = emailAddress;
// this.displayName = displayName;
// this.active = active;
// this.slug = slug;
// this.type = type;
// }
//
// public long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public boolean isActive() {
// return active;
// }
//
// public String getSlug() {
// return slug;
// }
//
// public UserType getType() {
// return type;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", emailAddress='" + emailAddress + '\'' +
// ", displayName='" + displayName + '\'' +
// ", active=" + active +
// ", slug='" + slug + '\'' +
// ", type='" + type + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// User user = (User) o;
// return java.util.Objects.equals(id, user.id) &&
// java.util.Objects.equals(active, user.active) &&
// java.util.Objects.equals(name, user.name) &&
// java.util.Objects.equals(emailAddress, user.emailAddress) &&
// java.util.Objects.equals(displayName, user.displayName) &&
// java.util.Objects.equals(slug, user.slug) &&
// java.util.Objects.equals(type, user.type);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(id, name, emailAddress, displayName, active, slug, type);
// }
// }
| import com.ccreanga.bitbucket.rest.client.model.User;
import java.util.Date; | package com.ccreanga.bitbucket.rest.client.model.pull.activity;
public class PullRequestUpdatedActivity extends PullRequestActivity {
public PullRequestUpdatedActivity() {
}
| // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/User.java
// public class User implements Serializable {
//
// private long id;
// private String name;
// private String emailAddress;
// private String displayName;
// private boolean active;
// private String slug;
// private UserType type;
//
// private User() {
// }
//
// public User(long id, String name, String emailAddress, String displayName, boolean active, String slug, UserType type) {
// this.id = id;
// this.name = name;
// this.emailAddress = emailAddress;
// this.displayName = displayName;
// this.active = active;
// this.slug = slug;
// this.type = type;
// }
//
// public long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public boolean isActive() {
// return active;
// }
//
// public String getSlug() {
// return slug;
// }
//
// public UserType getType() {
// return type;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", emailAddress='" + emailAddress + '\'' +
// ", displayName='" + displayName + '\'' +
// ", active=" + active +
// ", slug='" + slug + '\'' +
// ", type='" + type + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// User user = (User) o;
// return java.util.Objects.equals(id, user.id) &&
// java.util.Objects.equals(active, user.active) &&
// java.util.Objects.equals(name, user.name) &&
// java.util.Objects.equals(emailAddress, user.emailAddress) &&
// java.util.Objects.equals(displayName, user.displayName) &&
// java.util.Objects.equals(slug, user.slug) &&
// java.util.Objects.equals(type, user.type);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(id, name, emailAddress, displayName, active, slug, type);
// }
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/activity/PullRequestUpdatedActivity.java
import com.ccreanga.bitbucket.rest.client.model.User;
import java.util.Date;
package com.ccreanga.bitbucket.rest.client.model.pull.activity;
public class PullRequestUpdatedActivity extends PullRequestActivity {
public PullRequestUpdatedActivity() {
}
| public PullRequestUpdatedActivity(Long id, Date createdDate, User user, long pullRequestId) { |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/PullRequestBranchParser.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/PullRequestBranch.java
// public class PullRequestBranch implements Serializable {
//
// private String id;
// private String repositorySlug;
// private String repositoryName;
// private String projectKey;
//
// private PullRequestBranch() {
// }
//
// public PullRequestBranch(String id, String repositorySlug, String repositoryName, String projectKey) {
// this.id = id;
// this.repositorySlug = repositorySlug;
// this.repositoryName = repositoryName;
// this.projectKey = projectKey;
// }
//
// public String getId() {
// return id;
// }
//
// public String getRepositorySlug() {
// return repositorySlug;
// }
//
// public String getRepositoryName() {
// return repositoryName;
// }
//
// public String getProjectKey() {
// return projectKey;
// }
//
// @Override
// public String toString() {
// return "PullRequestBranch{" +
// "id='" + id + '\'' +
// ", repositorySlug='" + repositorySlug + '\'' +
// ", repositoryName='" + repositoryName + '\'' +
// ", projectKey='" + projectKey + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// PullRequestBranch that = (PullRequestBranch) o;
// return Objects.equals(id, that.id) &&
// Objects.equals(repositorySlug, that.repositorySlug) &&
// Objects.equals(repositoryName, that.repositoryName) &&
// Objects.equals(projectKey, that.projectKey);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(id, repositorySlug, repositoryName, projectKey);
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ParserUtil.java
// public static String optionalJsonString(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return null;
// return element.getAsString();
// }
| import com.ccreanga.bitbucket.rest.client.model.pull.PullRequestBranch;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.ParserUtil.optionalJsonString; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class PullRequestBranchParser implements Function<JsonElement, PullRequestBranch> {
@Override
public PullRequestBranch apply(JsonElement json) {
if (json == null || !json.isJsonObject()) {
return null;
}
JsonObject jsonObject = json.getAsJsonObject();
JsonObject repository = jsonObject.getAsJsonObject("repository");
JsonObject project = repository.getAsJsonObject("project");
return new PullRequestBranch(
jsonObject.get("id").getAsString(),
repository.get("slug").getAsString(), | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/PullRequestBranch.java
// public class PullRequestBranch implements Serializable {
//
// private String id;
// private String repositorySlug;
// private String repositoryName;
// private String projectKey;
//
// private PullRequestBranch() {
// }
//
// public PullRequestBranch(String id, String repositorySlug, String repositoryName, String projectKey) {
// this.id = id;
// this.repositorySlug = repositorySlug;
// this.repositoryName = repositoryName;
// this.projectKey = projectKey;
// }
//
// public String getId() {
// return id;
// }
//
// public String getRepositorySlug() {
// return repositorySlug;
// }
//
// public String getRepositoryName() {
// return repositoryName;
// }
//
// public String getProjectKey() {
// return projectKey;
// }
//
// @Override
// public String toString() {
// return "PullRequestBranch{" +
// "id='" + id + '\'' +
// ", repositorySlug='" + repositorySlug + '\'' +
// ", repositoryName='" + repositoryName + '\'' +
// ", projectKey='" + projectKey + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// PullRequestBranch that = (PullRequestBranch) o;
// return Objects.equals(id, that.id) &&
// Objects.equals(repositorySlug, that.repositorySlug) &&
// Objects.equals(repositoryName, that.repositoryName) &&
// Objects.equals(projectKey, that.projectKey);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(id, repositorySlug, repositoryName, projectKey);
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ParserUtil.java
// public static String optionalJsonString(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return null;
// return element.getAsString();
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/PullRequestBranchParser.java
import com.ccreanga.bitbucket.rest.client.model.pull.PullRequestBranch;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.ParserUtil.optionalJsonString;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class PullRequestBranchParser implements Function<JsonElement, PullRequestBranch> {
@Override
public PullRequestBranch apply(JsonElement json) {
if (json == null || !json.isJsonObject()) {
return null;
}
JsonObject jsonObject = json.getAsJsonObject();
JsonObject repository = jsonObject.getAsJsonObject("repository");
JsonObject project = repository.getAsJsonObject("project");
return new PullRequestBranch(
jsonObject.get("id").getAsString(),
repository.get("slug").getAsString(), | optionalJsonString(repository, "name"), |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/LinkParser.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Link.java
// public class Link implements Serializable {
// private String href;
// private String name;
//
// private Link() {
// }
//
// public Link(String href, String name) {
// this.href = href;
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public String getHref() {
// return href;
// }
//
// @Override
// public String toString() {
// return "Link{" +
// "href='" + href + '\'' +
// ", name='" + name + '\'' +
// '}';
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ParserUtil.java
// public static String optionalJsonString(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return null;
// return element.getAsString();
// }
| import com.ccreanga.bitbucket.rest.client.model.Link;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.ParserUtil.optionalJsonString; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
class LinkParser implements Function<JsonElement, Link> {
private String linkName="href";
private String textName="name";
public LinkParser() {
}
public LinkParser(String linkName, String textName) {
this.linkName = linkName;
this.textName = textName;
}
@Override
public Link apply(JsonElement jsonElement) {
JsonObject json = jsonElement.getAsJsonObject(); | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Link.java
// public class Link implements Serializable {
// private String href;
// private String name;
//
// private Link() {
// }
//
// public Link(String href, String name) {
// this.href = href;
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public String getHref() {
// return href;
// }
//
// @Override
// public String toString() {
// return "Link{" +
// "href='" + href + '\'' +
// ", name='" + name + '\'' +
// '}';
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ParserUtil.java
// public static String optionalJsonString(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return null;
// return element.getAsString();
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/LinkParser.java
import com.ccreanga.bitbucket.rest.client.model.Link;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.ParserUtil.optionalJsonString;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
class LinkParser implements Function<JsonElement, Link> {
private String linkName="href";
private String textName="name";
public LinkParser() {
}
public LinkParser(String linkName, String textName) {
this.linkName = linkName;
this.textName = textName;
}
@Override
public Link apply(JsonElement jsonElement) {
JsonObject json = jsonElement.getAsJsonObject(); | String href = optionalJsonString(json,linkName); |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/activity/PullRequestDeclinedActivity.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/User.java
// public class User implements Serializable {
//
// private long id;
// private String name;
// private String emailAddress;
// private String displayName;
// private boolean active;
// private String slug;
// private UserType type;
//
// private User() {
// }
//
// public User(long id, String name, String emailAddress, String displayName, boolean active, String slug, UserType type) {
// this.id = id;
// this.name = name;
// this.emailAddress = emailAddress;
// this.displayName = displayName;
// this.active = active;
// this.slug = slug;
// this.type = type;
// }
//
// public long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public boolean isActive() {
// return active;
// }
//
// public String getSlug() {
// return slug;
// }
//
// public UserType getType() {
// return type;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", emailAddress='" + emailAddress + '\'' +
// ", displayName='" + displayName + '\'' +
// ", active=" + active +
// ", slug='" + slug + '\'' +
// ", type='" + type + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// User user = (User) o;
// return java.util.Objects.equals(id, user.id) &&
// java.util.Objects.equals(active, user.active) &&
// java.util.Objects.equals(name, user.name) &&
// java.util.Objects.equals(emailAddress, user.emailAddress) &&
// java.util.Objects.equals(displayName, user.displayName) &&
// java.util.Objects.equals(slug, user.slug) &&
// java.util.Objects.equals(type, user.type);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(id, name, emailAddress, displayName, active, slug, type);
// }
// }
| import com.ccreanga.bitbucket.rest.client.model.User;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.model.pull.activity;
public class PullRequestDeclinedActivity extends PullRequestActivity{
protected PullRequestDeclinedActivity() {
}
| // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/User.java
// public class User implements Serializable {
//
// private long id;
// private String name;
// private String emailAddress;
// private String displayName;
// private boolean active;
// private String slug;
// private UserType type;
//
// private User() {
// }
//
// public User(long id, String name, String emailAddress, String displayName, boolean active, String slug, UserType type) {
// this.id = id;
// this.name = name;
// this.emailAddress = emailAddress;
// this.displayName = displayName;
// this.active = active;
// this.slug = slug;
// this.type = type;
// }
//
// public long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public boolean isActive() {
// return active;
// }
//
// public String getSlug() {
// return slug;
// }
//
// public UserType getType() {
// return type;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", emailAddress='" + emailAddress + '\'' +
// ", displayName='" + displayName + '\'' +
// ", active=" + active +
// ", slug='" + slug + '\'' +
// ", type='" + type + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// User user = (User) o;
// return java.util.Objects.equals(id, user.id) &&
// java.util.Objects.equals(active, user.active) &&
// java.util.Objects.equals(name, user.name) &&
// java.util.Objects.equals(emailAddress, user.emailAddress) &&
// java.util.Objects.equals(displayName, user.displayName) &&
// java.util.Objects.equals(slug, user.slug) &&
// java.util.Objects.equals(type, user.type);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(id, name, emailAddress, displayName, active, slug, type);
// }
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/activity/PullRequestDeclinedActivity.java
import com.ccreanga.bitbucket.rest.client.model.User;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.model.pull.activity;
public class PullRequestDeclinedActivity extends PullRequestActivity{
protected PullRequestDeclinedActivity() {
}
| public PullRequestDeclinedActivity(Long id, Date createdDate, User user, long pullRequestId) { |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/activity/PullRequestActivity.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/User.java
// public class User implements Serializable {
//
// private long id;
// private String name;
// private String emailAddress;
// private String displayName;
// private boolean active;
// private String slug;
// private UserType type;
//
// private User() {
// }
//
// public User(long id, String name, String emailAddress, String displayName, boolean active, String slug, UserType type) {
// this.id = id;
// this.name = name;
// this.emailAddress = emailAddress;
// this.displayName = displayName;
// this.active = active;
// this.slug = slug;
// this.type = type;
// }
//
// public long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public boolean isActive() {
// return active;
// }
//
// public String getSlug() {
// return slug;
// }
//
// public UserType getType() {
// return type;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", emailAddress='" + emailAddress + '\'' +
// ", displayName='" + displayName + '\'' +
// ", active=" + active +
// ", slug='" + slug + '\'' +
// ", type='" + type + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// User user = (User) o;
// return java.util.Objects.equals(id, user.id) &&
// java.util.Objects.equals(active, user.active) &&
// java.util.Objects.equals(name, user.name) &&
// java.util.Objects.equals(emailAddress, user.emailAddress) &&
// java.util.Objects.equals(displayName, user.displayName) &&
// java.util.Objects.equals(slug, user.slug) &&
// java.util.Objects.equals(type, user.type);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(id, name, emailAddress, displayName, active, slug, type);
// }
// }
| import com.ccreanga.bitbucket.rest.client.model.User;
import java.io.Serializable;
import java.util.Date; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.model.pull.activity;
public abstract class PullRequestActivity implements Serializable {
protected Long id;
protected Date createdDate; | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/User.java
// public class User implements Serializable {
//
// private long id;
// private String name;
// private String emailAddress;
// private String displayName;
// private boolean active;
// private String slug;
// private UserType type;
//
// private User() {
// }
//
// public User(long id, String name, String emailAddress, String displayName, boolean active, String slug, UserType type) {
// this.id = id;
// this.name = name;
// this.emailAddress = emailAddress;
// this.displayName = displayName;
// this.active = active;
// this.slug = slug;
// this.type = type;
// }
//
// public long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public boolean isActive() {
// return active;
// }
//
// public String getSlug() {
// return slug;
// }
//
// public UserType getType() {
// return type;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", emailAddress='" + emailAddress + '\'' +
// ", displayName='" + displayName + '\'' +
// ", active=" + active +
// ", slug='" + slug + '\'' +
// ", type='" + type + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// User user = (User) o;
// return java.util.Objects.equals(id, user.id) &&
// java.util.Objects.equals(active, user.active) &&
// java.util.Objects.equals(name, user.name) &&
// java.util.Objects.equals(emailAddress, user.emailAddress) &&
// java.util.Objects.equals(displayName, user.displayName) &&
// java.util.Objects.equals(slug, user.slug) &&
// java.util.Objects.equals(type, user.type);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(id, name, emailAddress, displayName, active, slug, type);
// }
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/activity/PullRequestActivity.java
import com.ccreanga.bitbucket.rest.client.model.User;
import java.io.Serializable;
import java.util.Date;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.model.pull.activity;
public abstract class PullRequestActivity implements Serializable {
protected Long id;
protected Date createdDate; | protected User user; |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/UserParser.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/User.java
// public class User implements Serializable {
//
// private long id;
// private String name;
// private String emailAddress;
// private String displayName;
// private boolean active;
// private String slug;
// private UserType type;
//
// private User() {
// }
//
// public User(long id, String name, String emailAddress, String displayName, boolean active, String slug, UserType type) {
// this.id = id;
// this.name = name;
// this.emailAddress = emailAddress;
// this.displayName = displayName;
// this.active = active;
// this.slug = slug;
// this.type = type;
// }
//
// public long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public boolean isActive() {
// return active;
// }
//
// public String getSlug() {
// return slug;
// }
//
// public UserType getType() {
// return type;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", emailAddress='" + emailAddress + '\'' +
// ", displayName='" + displayName + '\'' +
// ", active=" + active +
// ", slug='" + slug + '\'' +
// ", type='" + type + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// User user = (User) o;
// return java.util.Objects.equals(id, user.id) &&
// java.util.Objects.equals(active, user.active) &&
// java.util.Objects.equals(name, user.name) &&
// java.util.Objects.equals(emailAddress, user.emailAddress) &&
// java.util.Objects.equals(displayName, user.displayName) &&
// java.util.Objects.equals(slug, user.slug) &&
// java.util.Objects.equals(type, user.type);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(id, name, emailAddress, displayName, active, slug, type);
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/UserType.java
// public enum UserType implements Serializable {
//
// NORMAL,SERVICE
// }
| import com.ccreanga.bitbucket.rest.client.model.User;
import com.ccreanga.bitbucket.rest.client.model.UserType;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class UserParser implements Function<JsonElement, User> {
@Override
public User apply(JsonElement jsonElement) {
JsonObject json = jsonElement.getAsJsonObject();
return new User(
json.get("id").getAsLong(),
json.get("name").getAsString(),
json.get("emailAddress").getAsString(),
json.get("displayName").getAsString(),
json.get("active").getAsBoolean(),
json.get("slug").getAsString(), | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/User.java
// public class User implements Serializable {
//
// private long id;
// private String name;
// private String emailAddress;
// private String displayName;
// private boolean active;
// private String slug;
// private UserType type;
//
// private User() {
// }
//
// public User(long id, String name, String emailAddress, String displayName, boolean active, String slug, UserType type) {
// this.id = id;
// this.name = name;
// this.emailAddress = emailAddress;
// this.displayName = displayName;
// this.active = active;
// this.slug = slug;
// this.type = type;
// }
//
// public long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public boolean isActive() {
// return active;
// }
//
// public String getSlug() {
// return slug;
// }
//
// public UserType getType() {
// return type;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", emailAddress='" + emailAddress + '\'' +
// ", displayName='" + displayName + '\'' +
// ", active=" + active +
// ", slug='" + slug + '\'' +
// ", type='" + type + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// User user = (User) o;
// return java.util.Objects.equals(id, user.id) &&
// java.util.Objects.equals(active, user.active) &&
// java.util.Objects.equals(name, user.name) &&
// java.util.Objects.equals(emailAddress, user.emailAddress) &&
// java.util.Objects.equals(displayName, user.displayName) &&
// java.util.Objects.equals(slug, user.slug) &&
// java.util.Objects.equals(type, user.type);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(id, name, emailAddress, displayName, active, slug, type);
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/UserType.java
// public enum UserType implements Serializable {
//
// NORMAL,SERVICE
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/UserParser.java
import com.ccreanga.bitbucket.rest.client.model.User;
import com.ccreanga.bitbucket.rest.client.model.UserType;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class UserParser implements Function<JsonElement, User> {
@Override
public User apply(JsonElement jsonElement) {
JsonObject json = jsonElement.getAsJsonObject();
return new User(
json.get("id").getAsLong(),
json.get("name").getAsString(),
json.get("emailAddress").getAsString(),
json.get("displayName").getAsString(),
json.get("active").getAsBoolean(),
json.get("slug").getAsString(), | UserType.valueOf(json.get("type").getAsString()) |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/PullRequestChange.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/FileChangeType.java
// public enum FileChangeType implements Serializable {
//
// MOVE,MODIFY,ADD
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/NodeType.java
// public enum NodeType implements Serializable {
//
// FILE
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Path.java
// public class Path implements Serializable {
//
// private String[] components;
//
// private Path() {
// }
//
// public Path(String[] components) {
// this.components = Arrays.copyOf(components,components.length);
// }
//
// public String toFilePath(){
// StringBuilder sb = new StringBuilder();
// for (int i = 0; i < components.length; i++) {
// sb.append(components[i]);
// if (i!=(components.length-1))
// sb.append(File.separatorChar);
// }
// return sb.toString();
// }
//
// private String getName(){
// return components[components.length-1];
// };
//
// @Override
// public String toString() {
// return "Path{"+toFilePath()+"}";
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Path path = (Path) o;
// return Objects.equals(toFilePath(), path.toFilePath());
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(components);
// }
// }
| import com.ccreanga.bitbucket.rest.client.model.FileChangeType;
import com.ccreanga.bitbucket.rest.client.model.NodeType;
import com.ccreanga.bitbucket.rest.client.model.Path;
import java.io.Serializable;
import java.util.Objects; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.model.pull;
public class PullRequestChange implements Serializable {
private String contentId;
private String fromContentId; | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/FileChangeType.java
// public enum FileChangeType implements Serializable {
//
// MOVE,MODIFY,ADD
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/NodeType.java
// public enum NodeType implements Serializable {
//
// FILE
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Path.java
// public class Path implements Serializable {
//
// private String[] components;
//
// private Path() {
// }
//
// public Path(String[] components) {
// this.components = Arrays.copyOf(components,components.length);
// }
//
// public String toFilePath(){
// StringBuilder sb = new StringBuilder();
// for (int i = 0; i < components.length; i++) {
// sb.append(components[i]);
// if (i!=(components.length-1))
// sb.append(File.separatorChar);
// }
// return sb.toString();
// }
//
// private String getName(){
// return components[components.length-1];
// };
//
// @Override
// public String toString() {
// return "Path{"+toFilePath()+"}";
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Path path = (Path) o;
// return Objects.equals(toFilePath(), path.toFilePath());
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(components);
// }
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/PullRequestChange.java
import com.ccreanga.bitbucket.rest.client.model.FileChangeType;
import com.ccreanga.bitbucket.rest.client.model.NodeType;
import com.ccreanga.bitbucket.rest.client.model.Path;
import java.io.Serializable;
import java.util.Objects;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.model.pull;
public class PullRequestChange implements Serializable {
private String contentId;
private String fromContentId; | private Path path; |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/PullRequestChange.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/FileChangeType.java
// public enum FileChangeType implements Serializable {
//
// MOVE,MODIFY,ADD
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/NodeType.java
// public enum NodeType implements Serializable {
//
// FILE
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Path.java
// public class Path implements Serializable {
//
// private String[] components;
//
// private Path() {
// }
//
// public Path(String[] components) {
// this.components = Arrays.copyOf(components,components.length);
// }
//
// public String toFilePath(){
// StringBuilder sb = new StringBuilder();
// for (int i = 0; i < components.length; i++) {
// sb.append(components[i]);
// if (i!=(components.length-1))
// sb.append(File.separatorChar);
// }
// return sb.toString();
// }
//
// private String getName(){
// return components[components.length-1];
// };
//
// @Override
// public String toString() {
// return "Path{"+toFilePath()+"}";
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Path path = (Path) o;
// return Objects.equals(toFilePath(), path.toFilePath());
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(components);
// }
// }
| import com.ccreanga.bitbucket.rest.client.model.FileChangeType;
import com.ccreanga.bitbucket.rest.client.model.NodeType;
import com.ccreanga.bitbucket.rest.client.model.Path;
import java.io.Serializable;
import java.util.Objects; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.model.pull;
public class PullRequestChange implements Serializable {
private String contentId;
private String fromContentId;
private Path path;
private Path srcPath; | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/FileChangeType.java
// public enum FileChangeType implements Serializable {
//
// MOVE,MODIFY,ADD
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/NodeType.java
// public enum NodeType implements Serializable {
//
// FILE
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Path.java
// public class Path implements Serializable {
//
// private String[] components;
//
// private Path() {
// }
//
// public Path(String[] components) {
// this.components = Arrays.copyOf(components,components.length);
// }
//
// public String toFilePath(){
// StringBuilder sb = new StringBuilder();
// for (int i = 0; i < components.length; i++) {
// sb.append(components[i]);
// if (i!=(components.length-1))
// sb.append(File.separatorChar);
// }
// return sb.toString();
// }
//
// private String getName(){
// return components[components.length-1];
// };
//
// @Override
// public String toString() {
// return "Path{"+toFilePath()+"}";
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Path path = (Path) o;
// return Objects.equals(toFilePath(), path.toFilePath());
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(components);
// }
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/PullRequestChange.java
import com.ccreanga.bitbucket.rest.client.model.FileChangeType;
import com.ccreanga.bitbucket.rest.client.model.NodeType;
import com.ccreanga.bitbucket.rest.client.model.Path;
import java.io.Serializable;
import java.util.Objects;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.model.pull;
public class PullRequestChange implements Serializable {
private String contentId;
private String fromContentId;
private Path path;
private Path srcPath; | private FileChangeType type; |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/PullRequestChange.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/FileChangeType.java
// public enum FileChangeType implements Serializable {
//
// MOVE,MODIFY,ADD
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/NodeType.java
// public enum NodeType implements Serializable {
//
// FILE
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Path.java
// public class Path implements Serializable {
//
// private String[] components;
//
// private Path() {
// }
//
// public Path(String[] components) {
// this.components = Arrays.copyOf(components,components.length);
// }
//
// public String toFilePath(){
// StringBuilder sb = new StringBuilder();
// for (int i = 0; i < components.length; i++) {
// sb.append(components[i]);
// if (i!=(components.length-1))
// sb.append(File.separatorChar);
// }
// return sb.toString();
// }
//
// private String getName(){
// return components[components.length-1];
// };
//
// @Override
// public String toString() {
// return "Path{"+toFilePath()+"}";
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Path path = (Path) o;
// return Objects.equals(toFilePath(), path.toFilePath());
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(components);
// }
// }
| import com.ccreanga.bitbucket.rest.client.model.FileChangeType;
import com.ccreanga.bitbucket.rest.client.model.NodeType;
import com.ccreanga.bitbucket.rest.client.model.Path;
import java.io.Serializable;
import java.util.Objects; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.model.pull;
public class PullRequestChange implements Serializable {
private String contentId;
private String fromContentId;
private Path path;
private Path srcPath;
private FileChangeType type;
private boolean executable;
private int percentUnchanged; | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/FileChangeType.java
// public enum FileChangeType implements Serializable {
//
// MOVE,MODIFY,ADD
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/NodeType.java
// public enum NodeType implements Serializable {
//
// FILE
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Path.java
// public class Path implements Serializable {
//
// private String[] components;
//
// private Path() {
// }
//
// public Path(String[] components) {
// this.components = Arrays.copyOf(components,components.length);
// }
//
// public String toFilePath(){
// StringBuilder sb = new StringBuilder();
// for (int i = 0; i < components.length; i++) {
// sb.append(components[i]);
// if (i!=(components.length-1))
// sb.append(File.separatorChar);
// }
// return sb.toString();
// }
//
// private String getName(){
// return components[components.length-1];
// };
//
// @Override
// public String toString() {
// return "Path{"+toFilePath()+"}";
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// Path path = (Path) o;
// return Objects.equals(toFilePath(), path.toFilePath());
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(components);
// }
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/PullRequestChange.java
import com.ccreanga.bitbucket.rest.client.model.FileChangeType;
import com.ccreanga.bitbucket.rest.client.model.NodeType;
import com.ccreanga.bitbucket.rest.client.model.Path;
import java.io.Serializable;
import java.util.Objects;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.model.pull;
public class PullRequestChange implements Serializable {
private String contentId;
private String fromContentId;
private Path path;
private Path srcPath;
private FileChangeType type;
private boolean executable;
private int percentUnchanged; | private NodeType nodeType; |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/activity/PullRequestMergedActivity.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/User.java
// public class User implements Serializable {
//
// private long id;
// private String name;
// private String emailAddress;
// private String displayName;
// private boolean active;
// private String slug;
// private UserType type;
//
// private User() {
// }
//
// public User(long id, String name, String emailAddress, String displayName, boolean active, String slug, UserType type) {
// this.id = id;
// this.name = name;
// this.emailAddress = emailAddress;
// this.displayName = displayName;
// this.active = active;
// this.slug = slug;
// this.type = type;
// }
//
// public long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public boolean isActive() {
// return active;
// }
//
// public String getSlug() {
// return slug;
// }
//
// public UserType getType() {
// return type;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", emailAddress='" + emailAddress + '\'' +
// ", displayName='" + displayName + '\'' +
// ", active=" + active +
// ", slug='" + slug + '\'' +
// ", type='" + type + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// User user = (User) o;
// return java.util.Objects.equals(id, user.id) &&
// java.util.Objects.equals(active, user.active) &&
// java.util.Objects.equals(name, user.name) &&
// java.util.Objects.equals(emailAddress, user.emailAddress) &&
// java.util.Objects.equals(displayName, user.displayName) &&
// java.util.Objects.equals(slug, user.slug) &&
// java.util.Objects.equals(type, user.type);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(id, name, emailAddress, displayName, active, slug, type);
// }
// }
| import com.ccreanga.bitbucket.rest.client.model.User;
import java.util.Date;
import java.util.Objects; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.model.pull.activity;
public class PullRequestMergedActivity extends PullRequestActivity{
protected PullRequestMergedActivity() {
}
| // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/User.java
// public class User implements Serializable {
//
// private long id;
// private String name;
// private String emailAddress;
// private String displayName;
// private boolean active;
// private String slug;
// private UserType type;
//
// private User() {
// }
//
// public User(long id, String name, String emailAddress, String displayName, boolean active, String slug, UserType type) {
// this.id = id;
// this.name = name;
// this.emailAddress = emailAddress;
// this.displayName = displayName;
// this.active = active;
// this.slug = slug;
// this.type = type;
// }
//
// public long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public boolean isActive() {
// return active;
// }
//
// public String getSlug() {
// return slug;
// }
//
// public UserType getType() {
// return type;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", emailAddress='" + emailAddress + '\'' +
// ", displayName='" + displayName + '\'' +
// ", active=" + active +
// ", slug='" + slug + '\'' +
// ", type='" + type + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// User user = (User) o;
// return java.util.Objects.equals(id, user.id) &&
// java.util.Objects.equals(active, user.active) &&
// java.util.Objects.equals(name, user.name) &&
// java.util.Objects.equals(emailAddress, user.emailAddress) &&
// java.util.Objects.equals(displayName, user.displayName) &&
// java.util.Objects.equals(slug, user.slug) &&
// java.util.Objects.equals(type, user.type);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(id, name, emailAddress, displayName, active, slug, type);
// }
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/activity/PullRequestMergedActivity.java
import com.ccreanga.bitbucket.rest.client.model.User;
import java.util.Date;
import java.util.Objects;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.model.pull.activity;
public class PullRequestMergedActivity extends PullRequestActivity{
protected PullRequestMergedActivity() {
}
| public PullRequestMergedActivity(Long id, Date createdDate, User user, long pullRequestId) { |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/CommentAnchorParser.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/CommentAnchor.java
// public class CommentAnchor implements Serializable {
//
// private String fromHash;
// @Nonnull
// private String toHash;
// private long line;
// private LineType lineType;
// private FileType fileType;
// @Nonnull
// private String path;
// private String srcPath;
// private boolean orphaned;
//
// private CommentAnchor() {
// }
//
// public CommentAnchor(String fromHash, String toHash, long line, LineType lineType, FileType fileType, String path, String srcPath, boolean orphaned) {
// this.fromHash = fromHash;
// this.toHash = toHash;
// this.line = line;
// this.lineType = lineType;
// this.fileType = fileType;
// this.path = path;
// this.srcPath = srcPath;
// this.orphaned = orphaned;
// }
//
// public String getFromHash() {
// return fromHash;
// }
//
// public String getToHash() {
// return toHash;
// }
//
// public long getLine() {
// return line;
// }
//
// public LineType getLineType() {
// return lineType;
// }
//
// public FileType getFileType() {
// return fileType;
// }
//
// public String getPath() {
// return path;
// }
//
// public String getSrcPath() {
// return srcPath;
// }
//
// public boolean isOrphaned() {
// return orphaned;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// CommentAnchor that = (CommentAnchor) o;
// return Objects.equals(line, that.line) &&
// Objects.equals(orphaned, that.orphaned) &&
// Objects.equals(fromHash, that.fromHash) &&
// Objects.equals(toHash, that.toHash) &&
// Objects.equals(lineType, that.lineType) &&
// Objects.equals(fileType, that.fileType) &&
// Objects.equals(path, that.path) &&
// Objects.equals(srcPath, that.srcPath);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(fromHash, toHash, line, lineType, fileType, path, srcPath, orphaned);
// }
//
// @Override
// public String toString() {
// return "CommentAnchor{" +
// "fromHash='" + fromHash + '\'' +
// ", toHash='" + toHash + '\'' +
// ", line=" + line +
// ", lineType=" + lineType +
// ", fileType=" + fileType +
// ", path='" + path + '\'' +
// ", srcPath='" + srcPath + '\'' +
// ", orphaned=" + orphaned +
// '}';
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/FileType.java
// public enum FileType implements Serializable {
// FROM,TO
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/LineType.java
// public enum LineType implements Serializable {
// ADDED,REMOVED,CONTEXT;
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ParserUtil.java
// public class ParserUtil {
//
// public static boolean optionalJsonBoolean(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return false;
// return element.getAsBoolean();
// }
//
// public static long optionalJsonLong(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return -1;
// return element.getAsLong();
// }
//
// public static String optionalJsonString(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return null;
// return element.getAsString();
// }
// }
| import com.ccreanga.bitbucket.rest.client.model.CommentAnchor;
import com.ccreanga.bitbucket.rest.client.model.FileType;
import com.ccreanga.bitbucket.rest.client.model.LineType;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.ParserUtil.*; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class CommentAnchorParser implements Function<JsonElement, CommentAnchor> {
@Override
public CommentAnchor apply(JsonElement jsonElement) {
if (jsonElement == null || !jsonElement.isJsonObject()) {
return null;
}
JsonObject json = jsonElement.getAsJsonObject();
return new CommentAnchor(
optionalJsonString(json, "fromHash"),
json.get("toHash").getAsString(),
optionalJsonLong(json, "line"), | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/CommentAnchor.java
// public class CommentAnchor implements Serializable {
//
// private String fromHash;
// @Nonnull
// private String toHash;
// private long line;
// private LineType lineType;
// private FileType fileType;
// @Nonnull
// private String path;
// private String srcPath;
// private boolean orphaned;
//
// private CommentAnchor() {
// }
//
// public CommentAnchor(String fromHash, String toHash, long line, LineType lineType, FileType fileType, String path, String srcPath, boolean orphaned) {
// this.fromHash = fromHash;
// this.toHash = toHash;
// this.line = line;
// this.lineType = lineType;
// this.fileType = fileType;
// this.path = path;
// this.srcPath = srcPath;
// this.orphaned = orphaned;
// }
//
// public String getFromHash() {
// return fromHash;
// }
//
// public String getToHash() {
// return toHash;
// }
//
// public long getLine() {
// return line;
// }
//
// public LineType getLineType() {
// return lineType;
// }
//
// public FileType getFileType() {
// return fileType;
// }
//
// public String getPath() {
// return path;
// }
//
// public String getSrcPath() {
// return srcPath;
// }
//
// public boolean isOrphaned() {
// return orphaned;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// CommentAnchor that = (CommentAnchor) o;
// return Objects.equals(line, that.line) &&
// Objects.equals(orphaned, that.orphaned) &&
// Objects.equals(fromHash, that.fromHash) &&
// Objects.equals(toHash, that.toHash) &&
// Objects.equals(lineType, that.lineType) &&
// Objects.equals(fileType, that.fileType) &&
// Objects.equals(path, that.path) &&
// Objects.equals(srcPath, that.srcPath);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(fromHash, toHash, line, lineType, fileType, path, srcPath, orphaned);
// }
//
// @Override
// public String toString() {
// return "CommentAnchor{" +
// "fromHash='" + fromHash + '\'' +
// ", toHash='" + toHash + '\'' +
// ", line=" + line +
// ", lineType=" + lineType +
// ", fileType=" + fileType +
// ", path='" + path + '\'' +
// ", srcPath='" + srcPath + '\'' +
// ", orphaned=" + orphaned +
// '}';
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/FileType.java
// public enum FileType implements Serializable {
// FROM,TO
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/LineType.java
// public enum LineType implements Serializable {
// ADDED,REMOVED,CONTEXT;
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ParserUtil.java
// public class ParserUtil {
//
// public static boolean optionalJsonBoolean(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return false;
// return element.getAsBoolean();
// }
//
// public static long optionalJsonLong(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return -1;
// return element.getAsLong();
// }
//
// public static String optionalJsonString(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return null;
// return element.getAsString();
// }
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/CommentAnchorParser.java
import com.ccreanga.bitbucket.rest.client.model.CommentAnchor;
import com.ccreanga.bitbucket.rest.client.model.FileType;
import com.ccreanga.bitbucket.rest.client.model.LineType;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.ParserUtil.*;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class CommentAnchorParser implements Function<JsonElement, CommentAnchor> {
@Override
public CommentAnchor apply(JsonElement jsonElement) {
if (jsonElement == null || !jsonElement.isJsonObject()) {
return null;
}
JsonObject json = jsonElement.getAsJsonObject();
return new CommentAnchor(
optionalJsonString(json, "fromHash"),
json.get("toHash").getAsString(),
optionalJsonLong(json, "line"), | json.has("lineType")?LineType.valueOf(json.get("lineType").getAsString()):null, |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/CommentAnchorParser.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/CommentAnchor.java
// public class CommentAnchor implements Serializable {
//
// private String fromHash;
// @Nonnull
// private String toHash;
// private long line;
// private LineType lineType;
// private FileType fileType;
// @Nonnull
// private String path;
// private String srcPath;
// private boolean orphaned;
//
// private CommentAnchor() {
// }
//
// public CommentAnchor(String fromHash, String toHash, long line, LineType lineType, FileType fileType, String path, String srcPath, boolean orphaned) {
// this.fromHash = fromHash;
// this.toHash = toHash;
// this.line = line;
// this.lineType = lineType;
// this.fileType = fileType;
// this.path = path;
// this.srcPath = srcPath;
// this.orphaned = orphaned;
// }
//
// public String getFromHash() {
// return fromHash;
// }
//
// public String getToHash() {
// return toHash;
// }
//
// public long getLine() {
// return line;
// }
//
// public LineType getLineType() {
// return lineType;
// }
//
// public FileType getFileType() {
// return fileType;
// }
//
// public String getPath() {
// return path;
// }
//
// public String getSrcPath() {
// return srcPath;
// }
//
// public boolean isOrphaned() {
// return orphaned;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// CommentAnchor that = (CommentAnchor) o;
// return Objects.equals(line, that.line) &&
// Objects.equals(orphaned, that.orphaned) &&
// Objects.equals(fromHash, that.fromHash) &&
// Objects.equals(toHash, that.toHash) &&
// Objects.equals(lineType, that.lineType) &&
// Objects.equals(fileType, that.fileType) &&
// Objects.equals(path, that.path) &&
// Objects.equals(srcPath, that.srcPath);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(fromHash, toHash, line, lineType, fileType, path, srcPath, orphaned);
// }
//
// @Override
// public String toString() {
// return "CommentAnchor{" +
// "fromHash='" + fromHash + '\'' +
// ", toHash='" + toHash + '\'' +
// ", line=" + line +
// ", lineType=" + lineType +
// ", fileType=" + fileType +
// ", path='" + path + '\'' +
// ", srcPath='" + srcPath + '\'' +
// ", orphaned=" + orphaned +
// '}';
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/FileType.java
// public enum FileType implements Serializable {
// FROM,TO
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/LineType.java
// public enum LineType implements Serializable {
// ADDED,REMOVED,CONTEXT;
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ParserUtil.java
// public class ParserUtil {
//
// public static boolean optionalJsonBoolean(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return false;
// return element.getAsBoolean();
// }
//
// public static long optionalJsonLong(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return -1;
// return element.getAsLong();
// }
//
// public static String optionalJsonString(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return null;
// return element.getAsString();
// }
// }
| import com.ccreanga.bitbucket.rest.client.model.CommentAnchor;
import com.ccreanga.bitbucket.rest.client.model.FileType;
import com.ccreanga.bitbucket.rest.client.model.LineType;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.ParserUtil.*; | /*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class CommentAnchorParser implements Function<JsonElement, CommentAnchor> {
@Override
public CommentAnchor apply(JsonElement jsonElement) {
if (jsonElement == null || !jsonElement.isJsonObject()) {
return null;
}
JsonObject json = jsonElement.getAsJsonObject();
return new CommentAnchor(
optionalJsonString(json, "fromHash"),
json.get("toHash").getAsString(),
optionalJsonLong(json, "line"),
json.has("lineType")?LineType.valueOf(json.get("lineType").getAsString()):null, | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/CommentAnchor.java
// public class CommentAnchor implements Serializable {
//
// private String fromHash;
// @Nonnull
// private String toHash;
// private long line;
// private LineType lineType;
// private FileType fileType;
// @Nonnull
// private String path;
// private String srcPath;
// private boolean orphaned;
//
// private CommentAnchor() {
// }
//
// public CommentAnchor(String fromHash, String toHash, long line, LineType lineType, FileType fileType, String path, String srcPath, boolean orphaned) {
// this.fromHash = fromHash;
// this.toHash = toHash;
// this.line = line;
// this.lineType = lineType;
// this.fileType = fileType;
// this.path = path;
// this.srcPath = srcPath;
// this.orphaned = orphaned;
// }
//
// public String getFromHash() {
// return fromHash;
// }
//
// public String getToHash() {
// return toHash;
// }
//
// public long getLine() {
// return line;
// }
//
// public LineType getLineType() {
// return lineType;
// }
//
// public FileType getFileType() {
// return fileType;
// }
//
// public String getPath() {
// return path;
// }
//
// public String getSrcPath() {
// return srcPath;
// }
//
// public boolean isOrphaned() {
// return orphaned;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// CommentAnchor that = (CommentAnchor) o;
// return Objects.equals(line, that.line) &&
// Objects.equals(orphaned, that.orphaned) &&
// Objects.equals(fromHash, that.fromHash) &&
// Objects.equals(toHash, that.toHash) &&
// Objects.equals(lineType, that.lineType) &&
// Objects.equals(fileType, that.fileType) &&
// Objects.equals(path, that.path) &&
// Objects.equals(srcPath, that.srcPath);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(fromHash, toHash, line, lineType, fileType, path, srcPath, orphaned);
// }
//
// @Override
// public String toString() {
// return "CommentAnchor{" +
// "fromHash='" + fromHash + '\'' +
// ", toHash='" + toHash + '\'' +
// ", line=" + line +
// ", lineType=" + lineType +
// ", fileType=" + fileType +
// ", path='" + path + '\'' +
// ", srcPath='" + srcPath + '\'' +
// ", orphaned=" + orphaned +
// '}';
// }
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/FileType.java
// public enum FileType implements Serializable {
// FROM,TO
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/LineType.java
// public enum LineType implements Serializable {
// ADDED,REMOVED,CONTEXT;
// }
//
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ParserUtil.java
// public class ParserUtil {
//
// public static boolean optionalJsonBoolean(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return false;
// return element.getAsBoolean();
// }
//
// public static long optionalJsonLong(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return -1;
// return element.getAsLong();
// }
//
// public static String optionalJsonString(JsonObject json, String name) {
// JsonElement element = json.get(name);
// if ((element == null) || (element.isJsonNull()))
// return null;
// return element.getAsString();
// }
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/CommentAnchorParser.java
import com.ccreanga.bitbucket.rest.client.model.CommentAnchor;
import com.ccreanga.bitbucket.rest.client.model.FileType;
import com.ccreanga.bitbucket.rest.client.model.LineType;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.ParserUtil.*;
/*
*
* *
* * 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.ccreanga.bitbucket.rest.client.http.responseparsers;
public class CommentAnchorParser implements Function<JsonElement, CommentAnchor> {
@Override
public CommentAnchor apply(JsonElement jsonElement) {
if (jsonElement == null || !jsonElement.isJsonObject()) {
return null;
}
JsonObject json = jsonElement.getAsJsonObject();
return new CommentAnchor(
optionalJsonString(json, "fromHash"),
json.get("toHash").getAsString(),
optionalJsonLong(json, "line"),
json.has("lineType")?LineType.valueOf(json.get("lineType").getAsString()):null, | json.has("fileType")?FileType.valueOf(json.get("fileType").getAsString()):null, |
cornelcreanga/bitbucket-rest-client | src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/activity/PullRequestReviewedActivity.java | // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/User.java
// public class User implements Serializable {
//
// private long id;
// private String name;
// private String emailAddress;
// private String displayName;
// private boolean active;
// private String slug;
// private UserType type;
//
// private User() {
// }
//
// public User(long id, String name, String emailAddress, String displayName, boolean active, String slug, UserType type) {
// this.id = id;
// this.name = name;
// this.emailAddress = emailAddress;
// this.displayName = displayName;
// this.active = active;
// this.slug = slug;
// this.type = type;
// }
//
// public long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public boolean isActive() {
// return active;
// }
//
// public String getSlug() {
// return slug;
// }
//
// public UserType getType() {
// return type;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", emailAddress='" + emailAddress + '\'' +
// ", displayName='" + displayName + '\'' +
// ", active=" + active +
// ", slug='" + slug + '\'' +
// ", type='" + type + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// User user = (User) o;
// return java.util.Objects.equals(id, user.id) &&
// java.util.Objects.equals(active, user.active) &&
// java.util.Objects.equals(name, user.name) &&
// java.util.Objects.equals(emailAddress, user.emailAddress) &&
// java.util.Objects.equals(displayName, user.displayName) &&
// java.util.Objects.equals(slug, user.slug) &&
// java.util.Objects.equals(type, user.type);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(id, name, emailAddress, displayName, active, slug, type);
// }
// }
| import com.ccreanga.bitbucket.rest.client.model.User;
import java.util.Date; | package com.ccreanga.bitbucket.rest.client.model.pull.activity;
public class PullRequestReviewedActivity extends PullRequestActivity {
public PullRequestReviewedActivity() {
}
| // Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/User.java
// public class User implements Serializable {
//
// private long id;
// private String name;
// private String emailAddress;
// private String displayName;
// private boolean active;
// private String slug;
// private UserType type;
//
// private User() {
// }
//
// public User(long id, String name, String emailAddress, String displayName, boolean active, String slug, UserType type) {
// this.id = id;
// this.name = name;
// this.emailAddress = emailAddress;
// this.displayName = displayName;
// this.active = active;
// this.slug = slug;
// this.type = type;
// }
//
// public long getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public boolean isActive() {
// return active;
// }
//
// public String getSlug() {
// return slug;
// }
//
// public UserType getType() {
// return type;
// }
//
// @Override
// public String toString() {
// return "User{" +
// "id=" + id +
// ", name='" + name + '\'' +
// ", emailAddress='" + emailAddress + '\'' +
// ", displayName='" + displayName + '\'' +
// ", active=" + active +
// ", slug='" + slug + '\'' +
// ", type='" + type + '\'' +
// '}';
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// User user = (User) o;
// return java.util.Objects.equals(id, user.id) &&
// java.util.Objects.equals(active, user.active) &&
// java.util.Objects.equals(name, user.name) &&
// java.util.Objects.equals(emailAddress, user.emailAddress) &&
// java.util.Objects.equals(displayName, user.displayName) &&
// java.util.Objects.equals(slug, user.slug) &&
// java.util.Objects.equals(type, user.type);
// }
//
// @Override
// public int hashCode() {
// return java.util.Objects.hash(id, name, emailAddress, displayName, active, slug, type);
// }
// }
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/activity/PullRequestReviewedActivity.java
import com.ccreanga.bitbucket.rest.client.model.User;
import java.util.Date;
package com.ccreanga.bitbucket.rest.client.model.pull.activity;
public class PullRequestReviewedActivity extends PullRequestActivity {
public PullRequestReviewedActivity() {
}
| public PullRequestReviewedActivity(Long id, Date createdDate, User user, long pullRequestId) { |
josedab/spring-cloud-examples | zuul-proxy/svcb-service/src/main/java/com/josedab/example/clr/SocialProfileClr.java | // Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/model/SocialProfile.java
// @Entity
// public class SocialProfile {
//
// @Id
// @GeneratedValue
// private Long id;
// private String name;
//
// public SocialProfile() {}
//
// public SocialProfile(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
//
// }
//
// Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/repository/SocialProfileRepository.java
// @RepositoryRestResource
// public interface SocialProfileRepository extends JpaRepository<SocialProfile, Long> {
// @RestResource(path="by-name")
// Collection<SocialProfile> findByName(@Param("name") String name);
// }
| import java.util.stream.Stream;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import com.josedab.example.model.SocialProfile;
import com.josedab.example.repository.SocialProfileRepository; | package com.josedab.example.clr;
@Component
public class SocialProfileClr implements CommandLineRunner {
@Autowired | // Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/model/SocialProfile.java
// @Entity
// public class SocialProfile {
//
// @Id
// @GeneratedValue
// private Long id;
// private String name;
//
// public SocialProfile() {}
//
// public SocialProfile(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
//
// }
//
// Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/repository/SocialProfileRepository.java
// @RepositoryRestResource
// public interface SocialProfileRepository extends JpaRepository<SocialProfile, Long> {
// @RestResource(path="by-name")
// Collection<SocialProfile> findByName(@Param("name") String name);
// }
// Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/clr/SocialProfileClr.java
import java.util.stream.Stream;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import com.josedab.example.model.SocialProfile;
import com.josedab.example.repository.SocialProfileRepository;
package com.josedab.example.clr;
@Component
public class SocialProfileClr implements CommandLineRunner {
@Autowired | private SocialProfileRepository socialProfileRepository; |
josedab/spring-cloud-examples | zuul-proxy/svcb-service/src/main/java/com/josedab/example/clr/SocialProfileClr.java | // Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/model/SocialProfile.java
// @Entity
// public class SocialProfile {
//
// @Id
// @GeneratedValue
// private Long id;
// private String name;
//
// public SocialProfile() {}
//
// public SocialProfile(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
//
// }
//
// Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/repository/SocialProfileRepository.java
// @RepositoryRestResource
// public interface SocialProfileRepository extends JpaRepository<SocialProfile, Long> {
// @RestResource(path="by-name")
// Collection<SocialProfile> findByName(@Param("name") String name);
// }
| import java.util.stream.Stream;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import com.josedab.example.model.SocialProfile;
import com.josedab.example.repository.SocialProfileRepository; | package com.josedab.example.clr;
@Component
public class SocialProfileClr implements CommandLineRunner {
@Autowired
private SocialProfileRepository socialProfileRepository;
@Override
public void run(String... arg0) throws Exception {
Stream.<String>of("Kanye West",
"Rihanna",
"Imagine Dragons") | // Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/model/SocialProfile.java
// @Entity
// public class SocialProfile {
//
// @Id
// @GeneratedValue
// private Long id;
// private String name;
//
// public SocialProfile() {}
//
// public SocialProfile(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
//
// }
//
// Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/repository/SocialProfileRepository.java
// @RepositoryRestResource
// public interface SocialProfileRepository extends JpaRepository<SocialProfile, Long> {
// @RestResource(path="by-name")
// Collection<SocialProfile> findByName(@Param("name") String name);
// }
// Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/clr/SocialProfileClr.java
import java.util.stream.Stream;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import com.josedab.example.model.SocialProfile;
import com.josedab.example.repository.SocialProfileRepository;
package com.josedab.example.clr;
@Component
public class SocialProfileClr implements CommandLineRunner {
@Autowired
private SocialProfileRepository socialProfileRepository;
@Override
public void run(String... arg0) throws Exception {
Stream.<String>of("Kanye West",
"Rihanna",
"Imagine Dragons") | .forEach(name -> socialProfileRepository.save(new SocialProfile(name))); |
josedab/spring-cloud-examples | zipkin-distributed-tracing/zuul-service/src/main/java/com/josedab/example/controller/SocialProfileApiGatewayController.java | // Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/model/SocialProfile.java
// @Entity
// public class SocialProfile {
//
// @Id
// @GeneratedValue
// private Long id;
// private String name;
//
// public SocialProfile() {}
//
// public SocialProfile(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
//
// }
| import java.util.ArrayList;
import java.util.Collection;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.hateoas.Resources;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import com.josedab.example.model.SocialProfile;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; | package com.josedab.example.controller;
@RestController
@RequestMapping("/profiles")
public class SocialProfileApiGatewayController {
private static final String SERVICE_A = "svca-service";
private static final String SERVICE_B = "svcb-service";
@Autowired
private RestTemplate restTemplate;
@HystrixCommand(fallbackMethod = "getProfileNamesFallback")
@RequestMapping(method=RequestMethod.GET, value="/names/{service}")
public Collection<String> getProfileNamesForService(@PathVariable("service") String service) { | // Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/model/SocialProfile.java
// @Entity
// public class SocialProfile {
//
// @Id
// @GeneratedValue
// private Long id;
// private String name;
//
// public SocialProfile() {}
//
// public SocialProfile(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
//
// }
// Path: zipkin-distributed-tracing/zuul-service/src/main/java/com/josedab/example/controller/SocialProfileApiGatewayController.java
import java.util.ArrayList;
import java.util.Collection;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.hateoas.Resources;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import com.josedab.example.model.SocialProfile;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
package com.josedab.example.controller;
@RestController
@RequestMapping("/profiles")
public class SocialProfileApiGatewayController {
private static final String SERVICE_A = "svca-service";
private static final String SERVICE_B = "svcb-service";
@Autowired
private RestTemplate restTemplate;
@HystrixCommand(fallbackMethod = "getProfileNamesFallback")
@RequestMapping(method=RequestMethod.GET, value="/names/{service}")
public Collection<String> getProfileNamesForService(@PathVariable("service") String service) { | ParameterizedTypeReference<Resources<SocialProfile>> typeReference = new ParameterizedTypeReference<Resources<SocialProfile>>() {}; |
josedab/spring-cloud-examples | zuul-proxy/svca-service/src/main/java/com/josedab/example/clr/SocialProfileClr.java | // Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/model/SocialProfile.java
// @Entity
// public class SocialProfile {
//
// @Id
// @GeneratedValue
// private Long id;
// private String name;
//
// public SocialProfile() {}
//
// public SocialProfile(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
//
// }
//
// Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/repository/SocialProfileRepository.java
// @RepositoryRestResource
// public interface SocialProfileRepository extends JpaRepository<SocialProfile, Long> {
// @RestResource(path="by-name")
// Collection<SocialProfile> findByName(@Param("name") String name);
// }
| import java.util.stream.Stream;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import com.josedab.example.model.SocialProfile;
import com.josedab.example.repository.SocialProfileRepository; | package com.josedab.example.clr;
@Component
public class SocialProfileClr implements CommandLineRunner {
@Autowired | // Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/model/SocialProfile.java
// @Entity
// public class SocialProfile {
//
// @Id
// @GeneratedValue
// private Long id;
// private String name;
//
// public SocialProfile() {}
//
// public SocialProfile(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
//
// }
//
// Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/repository/SocialProfileRepository.java
// @RepositoryRestResource
// public interface SocialProfileRepository extends JpaRepository<SocialProfile, Long> {
// @RestResource(path="by-name")
// Collection<SocialProfile> findByName(@Param("name") String name);
// }
// Path: zuul-proxy/svca-service/src/main/java/com/josedab/example/clr/SocialProfileClr.java
import java.util.stream.Stream;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import com.josedab.example.model.SocialProfile;
import com.josedab.example.repository.SocialProfileRepository;
package com.josedab.example.clr;
@Component
public class SocialProfileClr implements CommandLineRunner {
@Autowired | private SocialProfileRepository socialProfileRepository; |
josedab/spring-cloud-examples | zuul-proxy/svca-service/src/main/java/com/josedab/example/clr/SocialProfileClr.java | // Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/model/SocialProfile.java
// @Entity
// public class SocialProfile {
//
// @Id
// @GeneratedValue
// private Long id;
// private String name;
//
// public SocialProfile() {}
//
// public SocialProfile(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
//
// }
//
// Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/repository/SocialProfileRepository.java
// @RepositoryRestResource
// public interface SocialProfileRepository extends JpaRepository<SocialProfile, Long> {
// @RestResource(path="by-name")
// Collection<SocialProfile> findByName(@Param("name") String name);
// }
| import java.util.stream.Stream;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import com.josedab.example.model.SocialProfile;
import com.josedab.example.repository.SocialProfileRepository; | package com.josedab.example.clr;
@Component
public class SocialProfileClr implements CommandLineRunner {
@Autowired
private SocialProfileRepository socialProfileRepository;
@Override
public void run(String... arg0) throws Exception {
Stream.<String>of("Katy Perry",
"Justin Bieber",
"Taylor Swift",
"Barack Obama",
"Youtube",
"Rihanna",
"Lady Gaga") | // Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/model/SocialProfile.java
// @Entity
// public class SocialProfile {
//
// @Id
// @GeneratedValue
// private Long id;
// private String name;
//
// public SocialProfile() {}
//
// public SocialProfile(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
//
// }
//
// Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/repository/SocialProfileRepository.java
// @RepositoryRestResource
// public interface SocialProfileRepository extends JpaRepository<SocialProfile, Long> {
// @RestResource(path="by-name")
// Collection<SocialProfile> findByName(@Param("name") String name);
// }
// Path: zuul-proxy/svca-service/src/main/java/com/josedab/example/clr/SocialProfileClr.java
import java.util.stream.Stream;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import com.josedab.example.model.SocialProfile;
import com.josedab.example.repository.SocialProfileRepository;
package com.josedab.example.clr;
@Component
public class SocialProfileClr implements CommandLineRunner {
@Autowired
private SocialProfileRepository socialProfileRepository;
@Override
public void run(String... arg0) throws Exception {
Stream.<String>of("Katy Perry",
"Justin Bieber",
"Taylor Swift",
"Barack Obama",
"Youtube",
"Rihanna",
"Lady Gaga") | .forEach(name -> socialProfileRepository.save(new SocialProfile(name))); |
josedab/spring-cloud-examples | zuul-proxy-cloud-bus/svca-service/src/main/java/com/josedab/example/processor/SocialProfileProcessor.java | // Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/model/SocialProfile.java
// @Entity
// public class SocialProfile {
//
// @Id
// @GeneratedValue
// private Long id;
// private String name;
//
// public SocialProfile() {}
//
// public SocialProfile(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
//
// }
//
// Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/repository/SocialProfileRepository.java
// @RepositoryRestResource
// public interface SocialProfileRepository extends JpaRepository<SocialProfile, Long> {
// @RestResource(path="by-name")
// Collection<SocialProfile> findByName(@Param("name") String name);
// }
| import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.annotation.ServiceActivator;
import com.josedab.example.model.SocialProfile;
import com.josedab.example.repository.SocialProfileRepository; | package com.josedab.example.processor;
@MessageEndpoint
public class SocialProfileProcessor {
@Autowired | // Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/model/SocialProfile.java
// @Entity
// public class SocialProfile {
//
// @Id
// @GeneratedValue
// private Long id;
// private String name;
//
// public SocialProfile() {}
//
// public SocialProfile(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
//
// }
//
// Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/repository/SocialProfileRepository.java
// @RepositoryRestResource
// public interface SocialProfileRepository extends JpaRepository<SocialProfile, Long> {
// @RestResource(path="by-name")
// Collection<SocialProfile> findByName(@Param("name") String name);
// }
// Path: zuul-proxy-cloud-bus/svca-service/src/main/java/com/josedab/example/processor/SocialProfileProcessor.java
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.annotation.ServiceActivator;
import com.josedab.example.model.SocialProfile;
import com.josedab.example.repository.SocialProfileRepository;
package com.josedab.example.processor;
@MessageEndpoint
public class SocialProfileProcessor {
@Autowired | private SocialProfileRepository socialProfileRepository; |
josedab/spring-cloud-examples | zuul-proxy-cloud-bus/svca-service/src/main/java/com/josedab/example/processor/SocialProfileProcessor.java | // Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/model/SocialProfile.java
// @Entity
// public class SocialProfile {
//
// @Id
// @GeneratedValue
// private Long id;
// private String name;
//
// public SocialProfile() {}
//
// public SocialProfile(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
//
// }
//
// Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/repository/SocialProfileRepository.java
// @RepositoryRestResource
// public interface SocialProfileRepository extends JpaRepository<SocialProfile, Long> {
// @RestResource(path="by-name")
// Collection<SocialProfile> findByName(@Param("name") String name);
// }
| import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.annotation.ServiceActivator;
import com.josedab.example.model.SocialProfile;
import com.josedab.example.repository.SocialProfileRepository; | package com.josedab.example.processor;
@MessageEndpoint
public class SocialProfileProcessor {
@Autowired
private SocialProfileRepository socialProfileRepository;
@ServiceActivator(inputChannel = Sink.INPUT)
public void acceptNewProfiles(String profileName) {
System.out.println("Got new profile " + profileName); | // Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/model/SocialProfile.java
// @Entity
// public class SocialProfile {
//
// @Id
// @GeneratedValue
// private Long id;
// private String name;
//
// public SocialProfile() {}
//
// public SocialProfile(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
//
// }
//
// Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/repository/SocialProfileRepository.java
// @RepositoryRestResource
// public interface SocialProfileRepository extends JpaRepository<SocialProfile, Long> {
// @RestResource(path="by-name")
// Collection<SocialProfile> findByName(@Param("name") String name);
// }
// Path: zuul-proxy-cloud-bus/svca-service/src/main/java/com/josedab/example/processor/SocialProfileProcessor.java
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.annotation.ServiceActivator;
import com.josedab.example.model.SocialProfile;
import com.josedab.example.repository.SocialProfileRepository;
package com.josedab.example.processor;
@MessageEndpoint
public class SocialProfileProcessor {
@Autowired
private SocialProfileRepository socialProfileRepository;
@ServiceActivator(inputChannel = Sink.INPUT)
public void acceptNewProfiles(String profileName) {
System.out.println("Got new profile " + profileName); | socialProfileRepository.save(new SocialProfile(profileName)); |
josedab/spring-cloud-examples | zuul-proxy/zuul-service/src/main/java/com/josedab/example/controller/SocialProfileApiGatewayController.java | // Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/model/SocialProfile.java
// @Entity
// public class SocialProfile {
//
// @Id
// @GeneratedValue
// private Long id;
// private String name;
//
// public SocialProfile() {}
//
// public SocialProfile(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
//
// }
| import java.util.ArrayList;
import java.util.Collection;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.hateoas.Resources;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import com.josedab.example.model.SocialProfile;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; | package com.josedab.example.controller;
@RestController
@RequestMapping("/profiles")
public class SocialProfileApiGatewayController {
private static final String SERVICE_A = "svca-service";
private static final String SERVICE_B = "svcb-service";
@Autowired
private RestTemplate restTemplate;
@HystrixCommand(fallbackMethod = "getProfileNamesFallback")
@RequestMapping(method=RequestMethod.GET, value="/names/{service}")
public Collection<String> getProfileNamesForService(@PathVariable("service") String service) { | // Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/model/SocialProfile.java
// @Entity
// public class SocialProfile {
//
// @Id
// @GeneratedValue
// private Long id;
// private String name;
//
// public SocialProfile() {}
//
// public SocialProfile(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
//
// }
// Path: zuul-proxy/zuul-service/src/main/java/com/josedab/example/controller/SocialProfileApiGatewayController.java
import java.util.ArrayList;
import java.util.Collection;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.hateoas.Resources;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import com.josedab.example.model.SocialProfile;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
package com.josedab.example.controller;
@RestController
@RequestMapping("/profiles")
public class SocialProfileApiGatewayController {
private static final String SERVICE_A = "svca-service";
private static final String SERVICE_B = "svcb-service";
@Autowired
private RestTemplate restTemplate;
@HystrixCommand(fallbackMethod = "getProfileNamesFallback")
@RequestMapping(method=RequestMethod.GET, value="/names/{service}")
public Collection<String> getProfileNamesForService(@PathVariable("service") String service) { | ParameterizedTypeReference<Resources<SocialProfile>> typeReference = new ParameterizedTypeReference<Resources<SocialProfile>>() {}; |
josedab/spring-cloud-examples | zuul-proxy-cloud-bus/zuul-service/src/main/java/com/josedab/example/controller/SocialProfileApiGatewayController.java | // Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/model/SocialProfile.java
// @Entity
// public class SocialProfile {
//
// @Id
// @GeneratedValue
// private Long id;
// private String name;
//
// public SocialProfile() {}
//
// public SocialProfile(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
//
// }
| import java.util.ArrayList;
import java.util.Collection;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.Output;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.hateoas.Resources;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import com.josedab.example.model.SocialProfile;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; | package com.josedab.example.controller;
@RestController
@RequestMapping("/profiles")
public class SocialProfileApiGatewayController {
private static final String SERVICE_A = "svca-service";
private static final String SERVICE_B = "svcb-service";
@Autowired
private RestTemplate restTemplate;
@Autowired
private Source source;
@HystrixCommand(fallbackMethod = "getProfileNamesFallback")
@RequestMapping(method=RequestMethod.GET, value="/names/{service}")
public Collection<String> getProfileNamesForService(@PathVariable("service") String service) {
try { | // Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/model/SocialProfile.java
// @Entity
// public class SocialProfile {
//
// @Id
// @GeneratedValue
// private Long id;
// private String name;
//
// public SocialProfile() {}
//
// public SocialProfile(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
//
// }
// Path: zuul-proxy-cloud-bus/zuul-service/src/main/java/com/josedab/example/controller/SocialProfileApiGatewayController.java
import java.util.ArrayList;
import java.util.Collection;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.Output;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.hateoas.Resources;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import com.josedab.example.model.SocialProfile;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
package com.josedab.example.controller;
@RestController
@RequestMapping("/profiles")
public class SocialProfileApiGatewayController {
private static final String SERVICE_A = "svca-service";
private static final String SERVICE_B = "svcb-service";
@Autowired
private RestTemplate restTemplate;
@Autowired
private Source source;
@HystrixCommand(fallbackMethod = "getProfileNamesFallback")
@RequestMapping(method=RequestMethod.GET, value="/names/{service}")
public Collection<String> getProfileNamesForService(@PathVariable("service") String service) {
try { | ParameterizedTypeReference<Resources<SocialProfile>> typeReference = new ParameterizedTypeReference<Resources<SocialProfile>>() { |
josedab/spring-cloud-examples | zuul-proxy-cloud-bus/svcb-service/src/main/java/com/josedab/example/processor/SocialProfileProcessor.java | // Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/model/SocialProfile.java
// @Entity
// public class SocialProfile {
//
// @Id
// @GeneratedValue
// private Long id;
// private String name;
//
// public SocialProfile() {}
//
// public SocialProfile(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
//
// }
//
// Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/repository/SocialProfileRepository.java
// @RepositoryRestResource
// public interface SocialProfileRepository extends JpaRepository<SocialProfile, Long> {
// @RestResource(path="by-name")
// Collection<SocialProfile> findByName(@Param("name") String name);
// }
| import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.annotation.ServiceActivator;
import com.josedab.example.model.SocialProfile;
import com.josedab.example.repository.SocialProfileRepository; | package com.josedab.example.processor;
@MessageEndpoint
public class SocialProfileProcessor {
@Autowired | // Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/model/SocialProfile.java
// @Entity
// public class SocialProfile {
//
// @Id
// @GeneratedValue
// private Long id;
// private String name;
//
// public SocialProfile() {}
//
// public SocialProfile(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
//
// }
//
// Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/repository/SocialProfileRepository.java
// @RepositoryRestResource
// public interface SocialProfileRepository extends JpaRepository<SocialProfile, Long> {
// @RestResource(path="by-name")
// Collection<SocialProfile> findByName(@Param("name") String name);
// }
// Path: zuul-proxy-cloud-bus/svcb-service/src/main/java/com/josedab/example/processor/SocialProfileProcessor.java
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.annotation.ServiceActivator;
import com.josedab.example.model.SocialProfile;
import com.josedab.example.repository.SocialProfileRepository;
package com.josedab.example.processor;
@MessageEndpoint
public class SocialProfileProcessor {
@Autowired | private SocialProfileRepository socialProfileRepository; |
josedab/spring-cloud-examples | zuul-proxy-cloud-bus/svcb-service/src/main/java/com/josedab/example/processor/SocialProfileProcessor.java | // Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/model/SocialProfile.java
// @Entity
// public class SocialProfile {
//
// @Id
// @GeneratedValue
// private Long id;
// private String name;
//
// public SocialProfile() {}
//
// public SocialProfile(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
//
// }
//
// Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/repository/SocialProfileRepository.java
// @RepositoryRestResource
// public interface SocialProfileRepository extends JpaRepository<SocialProfile, Long> {
// @RestResource(path="by-name")
// Collection<SocialProfile> findByName(@Param("name") String name);
// }
| import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.annotation.ServiceActivator;
import com.josedab.example.model.SocialProfile;
import com.josedab.example.repository.SocialProfileRepository; | package com.josedab.example.processor;
@MessageEndpoint
public class SocialProfileProcessor {
@Autowired
private SocialProfileRepository socialProfileRepository;
@ServiceActivator(inputChannel = Sink.INPUT)
public void acceptNewProfiles(String profileName) { | // Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/model/SocialProfile.java
// @Entity
// public class SocialProfile {
//
// @Id
// @GeneratedValue
// private Long id;
// private String name;
//
// public SocialProfile() {}
//
// public SocialProfile(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
//
//
// }
//
// Path: zuul-proxy/svcb-service/src/main/java/com/josedab/example/repository/SocialProfileRepository.java
// @RepositoryRestResource
// public interface SocialProfileRepository extends JpaRepository<SocialProfile, Long> {
// @RestResource(path="by-name")
// Collection<SocialProfile> findByName(@Param("name") String name);
// }
// Path: zuul-proxy-cloud-bus/svcb-service/src/main/java/com/josedab/example/processor/SocialProfileProcessor.java
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.annotation.ServiceActivator;
import com.josedab.example.model.SocialProfile;
import com.josedab.example.repository.SocialProfileRepository;
package com.josedab.example.processor;
@MessageEndpoint
public class SocialProfileProcessor {
@Autowired
private SocialProfileRepository socialProfileRepository;
@ServiceActivator(inputChannel = Sink.INPUT)
public void acceptNewProfiles(String profileName) { | socialProfileRepository.save(new SocialProfile(profileName)); |
highway-to-urhell/highway-to-urhell | h2hell-core/src/test/java/com/highway2urhell/collector/Struts1CollectorTest.java | // Path: h2hell-core/src/main/java/com/highway2urhell/transformer/Struts1Transformer.java
// public class Struts1Transformer extends AbstractLeechTransformer {
//
// public Struts1Transformer() {
// super("org/apache/struts/action/ActionServlet");
// addImportPackage(collectPackages());
// }
//
// public static String[] collectPackages() {
// return new String[]{
// "com.highway2urhell",
// "com.highway2urhell.domain",
// "java.lang.reflect",
// "java.util",
// "org.apache.commons.digester",
// "org.apache.struts.action",
// "org.apache.struts.config.impl"
// };
// }
//
// @Override
// protected void doTransform(CtClass cc) throws Exception {
// CtMethod m = cc.getMethod("destroyConfigDigester", "()V");
// m.insertBefore(collectBody());
// }
//
// public static String collectBody() {
// return "{\n" +
// " ModuleConfigImpl m = (ModuleConfigImpl) configDigester.getRoot();\n" +
// " Field f;\n" +
// " List listEntryPath = new ArrayList();\n" +
// " try {\n" +
// " f = m.getClass().getDeclaredField(\"actionConfigList\");\n" +
// " f.setAccessible(true);\n" +
// " List res = (ArrayList) f.get(m);\n" +
// " if (res != null) {\n" +
// " Iterator iter = res.iterator();\n" +
// " while (iter.hasNext()) {\n" +
// " ActionMapping action = (ActionMapping) iter.next();\n" +
// " if (action.getType() != null && !\"\".equals(action.getType())) {\n" +
// " try {\n" +
// " Class c = Class.forName(action.getType());\n" +
// " Method[] tabMet = c.getDeclaredMethods();\n" +
// " for (int i = 0; i < tabMet.length; i++) {\n" +
// " EntryPathData entry = new EntryPathData();\n" +
// " entry.setClassName(action.getType());\n" +
// " entry.setMethodName(tabMet[i].getName());\n" +
// " if (action.getPrefix() != null && !\"null\".equals(action.getPrefix())) {\n" +
// " entry.setUri(action.getPrefix() + action.getPath());\n" +
// " } else {\n" +
// " entry.setUri(action.getPath());\n" +
// " }\n" +
// " entry.setTypePath(TypePath.DYNAMIC);\n" +
// " List listEntryPathData = new ArrayList();\n" +
// " for (int j = 0; j < tabMet[i].getParameterTypes().length; j++) {\n" +
// " EntryPathParam param = new EntryPathParam();\n" +
// " param.setKey(\"\");\n" +
// " param.setTypeParam(TypeParam.PARAM_DATA);\n" +
// " param.setValue(tabMet[i].getParameterTypes()[j].getName());\n" +
// " listEntryPathData.add(param);\n" +
// " }\n" +
// " entry.setListEntryPathData(listEntryPathData);\n" +
// " entry.setSignatureName(org.objectweb.asm.Type.getMethodDescriptor(tabMet[i]));\n" +
// " listEntryPath.add(entry);\n" +
// " }\n" +
// " } catch (ClassNotFoundException e) {\n" +
// " e.printStackTrace();\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " } catch (Exception e) {\n" +
// " e.printStackTrace();\n" +
// " }\n" +
// " CoreEngine.getInstance().getFramework(\"STRUTS_1\").receiveData(listEntryPath);\n" +
// "}";
// }
// }
//
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String extractBody(String in, String methodName) throws ParseException, FileNotFoundException {
// return extractMethod(JavaParser.parse(new FileInputStream(in)), methodName);
// }
//
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String[] extractPackages(String in) throws ParseException, FileNotFoundException {
// List<String> classes = extractImports(in);
// Set<String> ret = new TreeSet<String>();
// for (String aClass : classes) {
// ret.add(aClass.substring(0, aClass.lastIndexOf(".")));
// }
//
// return ret.toArray(new String[]{});
// }
| import com.github.javaparser.ParseException;
import com.highway2urhell.transformer.Struts1Transformer;
import org.junit.Test;
import java.io.FileNotFoundException;
import static com.highway2urhell.utils.ParsingUtil.extractBody;
import static com.highway2urhell.utils.ParsingUtil.extractPackages;
import static org.fest.assertions.Assertions.assertThat; | package com.highway2urhell.collector;
public class Struts1CollectorTest {
@Test
public void checkScript() throws FileNotFoundException, ParseException { | // Path: h2hell-core/src/main/java/com/highway2urhell/transformer/Struts1Transformer.java
// public class Struts1Transformer extends AbstractLeechTransformer {
//
// public Struts1Transformer() {
// super("org/apache/struts/action/ActionServlet");
// addImportPackage(collectPackages());
// }
//
// public static String[] collectPackages() {
// return new String[]{
// "com.highway2urhell",
// "com.highway2urhell.domain",
// "java.lang.reflect",
// "java.util",
// "org.apache.commons.digester",
// "org.apache.struts.action",
// "org.apache.struts.config.impl"
// };
// }
//
// @Override
// protected void doTransform(CtClass cc) throws Exception {
// CtMethod m = cc.getMethod("destroyConfigDigester", "()V");
// m.insertBefore(collectBody());
// }
//
// public static String collectBody() {
// return "{\n" +
// " ModuleConfigImpl m = (ModuleConfigImpl) configDigester.getRoot();\n" +
// " Field f;\n" +
// " List listEntryPath = new ArrayList();\n" +
// " try {\n" +
// " f = m.getClass().getDeclaredField(\"actionConfigList\");\n" +
// " f.setAccessible(true);\n" +
// " List res = (ArrayList) f.get(m);\n" +
// " if (res != null) {\n" +
// " Iterator iter = res.iterator();\n" +
// " while (iter.hasNext()) {\n" +
// " ActionMapping action = (ActionMapping) iter.next();\n" +
// " if (action.getType() != null && !\"\".equals(action.getType())) {\n" +
// " try {\n" +
// " Class c = Class.forName(action.getType());\n" +
// " Method[] tabMet = c.getDeclaredMethods();\n" +
// " for (int i = 0; i < tabMet.length; i++) {\n" +
// " EntryPathData entry = new EntryPathData();\n" +
// " entry.setClassName(action.getType());\n" +
// " entry.setMethodName(tabMet[i].getName());\n" +
// " if (action.getPrefix() != null && !\"null\".equals(action.getPrefix())) {\n" +
// " entry.setUri(action.getPrefix() + action.getPath());\n" +
// " } else {\n" +
// " entry.setUri(action.getPath());\n" +
// " }\n" +
// " entry.setTypePath(TypePath.DYNAMIC);\n" +
// " List listEntryPathData = new ArrayList();\n" +
// " for (int j = 0; j < tabMet[i].getParameterTypes().length; j++) {\n" +
// " EntryPathParam param = new EntryPathParam();\n" +
// " param.setKey(\"\");\n" +
// " param.setTypeParam(TypeParam.PARAM_DATA);\n" +
// " param.setValue(tabMet[i].getParameterTypes()[j].getName());\n" +
// " listEntryPathData.add(param);\n" +
// " }\n" +
// " entry.setListEntryPathData(listEntryPathData);\n" +
// " entry.setSignatureName(org.objectweb.asm.Type.getMethodDescriptor(tabMet[i]));\n" +
// " listEntryPath.add(entry);\n" +
// " }\n" +
// " } catch (ClassNotFoundException e) {\n" +
// " e.printStackTrace();\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " } catch (Exception e) {\n" +
// " e.printStackTrace();\n" +
// " }\n" +
// " CoreEngine.getInstance().getFramework(\"STRUTS_1\").receiveData(listEntryPath);\n" +
// "}";
// }
// }
//
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String extractBody(String in, String methodName) throws ParseException, FileNotFoundException {
// return extractMethod(JavaParser.parse(new FileInputStream(in)), methodName);
// }
//
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String[] extractPackages(String in) throws ParseException, FileNotFoundException {
// List<String> classes = extractImports(in);
// Set<String> ret = new TreeSet<String>();
// for (String aClass : classes) {
// ret.add(aClass.substring(0, aClass.lastIndexOf(".")));
// }
//
// return ret.toArray(new String[]{});
// }
// Path: h2hell-core/src/test/java/com/highway2urhell/collector/Struts1CollectorTest.java
import com.github.javaparser.ParseException;
import com.highway2urhell.transformer.Struts1Transformer;
import org.junit.Test;
import java.io.FileNotFoundException;
import static com.highway2urhell.utils.ParsingUtil.extractBody;
import static com.highway2urhell.utils.ParsingUtil.extractPackages;
import static org.fest.assertions.Assertions.assertThat;
package com.highway2urhell.collector;
public class Struts1CollectorTest {
@Test
public void checkScript() throws FileNotFoundException, ParseException { | assertThat(Struts1Transformer.collectBody()) |
highway-to-urhell/highway-to-urhell | h2hell-core/src/test/java/com/highway2urhell/collector/Struts1CollectorTest.java | // Path: h2hell-core/src/main/java/com/highway2urhell/transformer/Struts1Transformer.java
// public class Struts1Transformer extends AbstractLeechTransformer {
//
// public Struts1Transformer() {
// super("org/apache/struts/action/ActionServlet");
// addImportPackage(collectPackages());
// }
//
// public static String[] collectPackages() {
// return new String[]{
// "com.highway2urhell",
// "com.highway2urhell.domain",
// "java.lang.reflect",
// "java.util",
// "org.apache.commons.digester",
// "org.apache.struts.action",
// "org.apache.struts.config.impl"
// };
// }
//
// @Override
// protected void doTransform(CtClass cc) throws Exception {
// CtMethod m = cc.getMethod("destroyConfigDigester", "()V");
// m.insertBefore(collectBody());
// }
//
// public static String collectBody() {
// return "{\n" +
// " ModuleConfigImpl m = (ModuleConfigImpl) configDigester.getRoot();\n" +
// " Field f;\n" +
// " List listEntryPath = new ArrayList();\n" +
// " try {\n" +
// " f = m.getClass().getDeclaredField(\"actionConfigList\");\n" +
// " f.setAccessible(true);\n" +
// " List res = (ArrayList) f.get(m);\n" +
// " if (res != null) {\n" +
// " Iterator iter = res.iterator();\n" +
// " while (iter.hasNext()) {\n" +
// " ActionMapping action = (ActionMapping) iter.next();\n" +
// " if (action.getType() != null && !\"\".equals(action.getType())) {\n" +
// " try {\n" +
// " Class c = Class.forName(action.getType());\n" +
// " Method[] tabMet = c.getDeclaredMethods();\n" +
// " for (int i = 0; i < tabMet.length; i++) {\n" +
// " EntryPathData entry = new EntryPathData();\n" +
// " entry.setClassName(action.getType());\n" +
// " entry.setMethodName(tabMet[i].getName());\n" +
// " if (action.getPrefix() != null && !\"null\".equals(action.getPrefix())) {\n" +
// " entry.setUri(action.getPrefix() + action.getPath());\n" +
// " } else {\n" +
// " entry.setUri(action.getPath());\n" +
// " }\n" +
// " entry.setTypePath(TypePath.DYNAMIC);\n" +
// " List listEntryPathData = new ArrayList();\n" +
// " for (int j = 0; j < tabMet[i].getParameterTypes().length; j++) {\n" +
// " EntryPathParam param = new EntryPathParam();\n" +
// " param.setKey(\"\");\n" +
// " param.setTypeParam(TypeParam.PARAM_DATA);\n" +
// " param.setValue(tabMet[i].getParameterTypes()[j].getName());\n" +
// " listEntryPathData.add(param);\n" +
// " }\n" +
// " entry.setListEntryPathData(listEntryPathData);\n" +
// " entry.setSignatureName(org.objectweb.asm.Type.getMethodDescriptor(tabMet[i]));\n" +
// " listEntryPath.add(entry);\n" +
// " }\n" +
// " } catch (ClassNotFoundException e) {\n" +
// " e.printStackTrace();\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " } catch (Exception e) {\n" +
// " e.printStackTrace();\n" +
// " }\n" +
// " CoreEngine.getInstance().getFramework(\"STRUTS_1\").receiveData(listEntryPath);\n" +
// "}";
// }
// }
//
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String extractBody(String in, String methodName) throws ParseException, FileNotFoundException {
// return extractMethod(JavaParser.parse(new FileInputStream(in)), methodName);
// }
//
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String[] extractPackages(String in) throws ParseException, FileNotFoundException {
// List<String> classes = extractImports(in);
// Set<String> ret = new TreeSet<String>();
// for (String aClass : classes) {
// ret.add(aClass.substring(0, aClass.lastIndexOf(".")));
// }
//
// return ret.toArray(new String[]{});
// }
| import com.github.javaparser.ParseException;
import com.highway2urhell.transformer.Struts1Transformer;
import org.junit.Test;
import java.io.FileNotFoundException;
import static com.highway2urhell.utils.ParsingUtil.extractBody;
import static com.highway2urhell.utils.ParsingUtil.extractPackages;
import static org.fest.assertions.Assertions.assertThat; | package com.highway2urhell.collector;
public class Struts1CollectorTest {
@Test
public void checkScript() throws FileNotFoundException, ParseException {
assertThat(Struts1Transformer.collectBody()) | // Path: h2hell-core/src/main/java/com/highway2urhell/transformer/Struts1Transformer.java
// public class Struts1Transformer extends AbstractLeechTransformer {
//
// public Struts1Transformer() {
// super("org/apache/struts/action/ActionServlet");
// addImportPackage(collectPackages());
// }
//
// public static String[] collectPackages() {
// return new String[]{
// "com.highway2urhell",
// "com.highway2urhell.domain",
// "java.lang.reflect",
// "java.util",
// "org.apache.commons.digester",
// "org.apache.struts.action",
// "org.apache.struts.config.impl"
// };
// }
//
// @Override
// protected void doTransform(CtClass cc) throws Exception {
// CtMethod m = cc.getMethod("destroyConfigDigester", "()V");
// m.insertBefore(collectBody());
// }
//
// public static String collectBody() {
// return "{\n" +
// " ModuleConfigImpl m = (ModuleConfigImpl) configDigester.getRoot();\n" +
// " Field f;\n" +
// " List listEntryPath = new ArrayList();\n" +
// " try {\n" +
// " f = m.getClass().getDeclaredField(\"actionConfigList\");\n" +
// " f.setAccessible(true);\n" +
// " List res = (ArrayList) f.get(m);\n" +
// " if (res != null) {\n" +
// " Iterator iter = res.iterator();\n" +
// " while (iter.hasNext()) {\n" +
// " ActionMapping action = (ActionMapping) iter.next();\n" +
// " if (action.getType() != null && !\"\".equals(action.getType())) {\n" +
// " try {\n" +
// " Class c = Class.forName(action.getType());\n" +
// " Method[] tabMet = c.getDeclaredMethods();\n" +
// " for (int i = 0; i < tabMet.length; i++) {\n" +
// " EntryPathData entry = new EntryPathData();\n" +
// " entry.setClassName(action.getType());\n" +
// " entry.setMethodName(tabMet[i].getName());\n" +
// " if (action.getPrefix() != null && !\"null\".equals(action.getPrefix())) {\n" +
// " entry.setUri(action.getPrefix() + action.getPath());\n" +
// " } else {\n" +
// " entry.setUri(action.getPath());\n" +
// " }\n" +
// " entry.setTypePath(TypePath.DYNAMIC);\n" +
// " List listEntryPathData = new ArrayList();\n" +
// " for (int j = 0; j < tabMet[i].getParameterTypes().length; j++) {\n" +
// " EntryPathParam param = new EntryPathParam();\n" +
// " param.setKey(\"\");\n" +
// " param.setTypeParam(TypeParam.PARAM_DATA);\n" +
// " param.setValue(tabMet[i].getParameterTypes()[j].getName());\n" +
// " listEntryPathData.add(param);\n" +
// " }\n" +
// " entry.setListEntryPathData(listEntryPathData);\n" +
// " entry.setSignatureName(org.objectweb.asm.Type.getMethodDescriptor(tabMet[i]));\n" +
// " listEntryPath.add(entry);\n" +
// " }\n" +
// " } catch (ClassNotFoundException e) {\n" +
// " e.printStackTrace();\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " } catch (Exception e) {\n" +
// " e.printStackTrace();\n" +
// " }\n" +
// " CoreEngine.getInstance().getFramework(\"STRUTS_1\").receiveData(listEntryPath);\n" +
// "}";
// }
// }
//
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String extractBody(String in, String methodName) throws ParseException, FileNotFoundException {
// return extractMethod(JavaParser.parse(new FileInputStream(in)), methodName);
// }
//
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String[] extractPackages(String in) throws ParseException, FileNotFoundException {
// List<String> classes = extractImports(in);
// Set<String> ret = new TreeSet<String>();
// for (String aClass : classes) {
// ret.add(aClass.substring(0, aClass.lastIndexOf(".")));
// }
//
// return ret.toArray(new String[]{});
// }
// Path: h2hell-core/src/test/java/com/highway2urhell/collector/Struts1CollectorTest.java
import com.github.javaparser.ParseException;
import com.highway2urhell.transformer.Struts1Transformer;
import org.junit.Test;
import java.io.FileNotFoundException;
import static com.highway2urhell.utils.ParsingUtil.extractBody;
import static com.highway2urhell.utils.ParsingUtil.extractPackages;
import static org.fest.assertions.Assertions.assertThat;
package com.highway2urhell.collector;
public class Struts1CollectorTest {
@Test
public void checkScript() throws FileNotFoundException, ParseException {
assertThat(Struts1Transformer.collectBody()) | .isEqualTo(extractBody("./src/test/java/com/highway2urhell/collector/Struts1Collector.java", "collectBody")); |
highway-to-urhell/highway-to-urhell | h2hell-core/src/test/java/com/highway2urhell/collector/Struts1CollectorTest.java | // Path: h2hell-core/src/main/java/com/highway2urhell/transformer/Struts1Transformer.java
// public class Struts1Transformer extends AbstractLeechTransformer {
//
// public Struts1Transformer() {
// super("org/apache/struts/action/ActionServlet");
// addImportPackage(collectPackages());
// }
//
// public static String[] collectPackages() {
// return new String[]{
// "com.highway2urhell",
// "com.highway2urhell.domain",
// "java.lang.reflect",
// "java.util",
// "org.apache.commons.digester",
// "org.apache.struts.action",
// "org.apache.struts.config.impl"
// };
// }
//
// @Override
// protected void doTransform(CtClass cc) throws Exception {
// CtMethod m = cc.getMethod("destroyConfigDigester", "()V");
// m.insertBefore(collectBody());
// }
//
// public static String collectBody() {
// return "{\n" +
// " ModuleConfigImpl m = (ModuleConfigImpl) configDigester.getRoot();\n" +
// " Field f;\n" +
// " List listEntryPath = new ArrayList();\n" +
// " try {\n" +
// " f = m.getClass().getDeclaredField(\"actionConfigList\");\n" +
// " f.setAccessible(true);\n" +
// " List res = (ArrayList) f.get(m);\n" +
// " if (res != null) {\n" +
// " Iterator iter = res.iterator();\n" +
// " while (iter.hasNext()) {\n" +
// " ActionMapping action = (ActionMapping) iter.next();\n" +
// " if (action.getType() != null && !\"\".equals(action.getType())) {\n" +
// " try {\n" +
// " Class c = Class.forName(action.getType());\n" +
// " Method[] tabMet = c.getDeclaredMethods();\n" +
// " for (int i = 0; i < tabMet.length; i++) {\n" +
// " EntryPathData entry = new EntryPathData();\n" +
// " entry.setClassName(action.getType());\n" +
// " entry.setMethodName(tabMet[i].getName());\n" +
// " if (action.getPrefix() != null && !\"null\".equals(action.getPrefix())) {\n" +
// " entry.setUri(action.getPrefix() + action.getPath());\n" +
// " } else {\n" +
// " entry.setUri(action.getPath());\n" +
// " }\n" +
// " entry.setTypePath(TypePath.DYNAMIC);\n" +
// " List listEntryPathData = new ArrayList();\n" +
// " for (int j = 0; j < tabMet[i].getParameterTypes().length; j++) {\n" +
// " EntryPathParam param = new EntryPathParam();\n" +
// " param.setKey(\"\");\n" +
// " param.setTypeParam(TypeParam.PARAM_DATA);\n" +
// " param.setValue(tabMet[i].getParameterTypes()[j].getName());\n" +
// " listEntryPathData.add(param);\n" +
// " }\n" +
// " entry.setListEntryPathData(listEntryPathData);\n" +
// " entry.setSignatureName(org.objectweb.asm.Type.getMethodDescriptor(tabMet[i]));\n" +
// " listEntryPath.add(entry);\n" +
// " }\n" +
// " } catch (ClassNotFoundException e) {\n" +
// " e.printStackTrace();\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " } catch (Exception e) {\n" +
// " e.printStackTrace();\n" +
// " }\n" +
// " CoreEngine.getInstance().getFramework(\"STRUTS_1\").receiveData(listEntryPath);\n" +
// "}";
// }
// }
//
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String extractBody(String in, String methodName) throws ParseException, FileNotFoundException {
// return extractMethod(JavaParser.parse(new FileInputStream(in)), methodName);
// }
//
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String[] extractPackages(String in) throws ParseException, FileNotFoundException {
// List<String> classes = extractImports(in);
// Set<String> ret = new TreeSet<String>();
// for (String aClass : classes) {
// ret.add(aClass.substring(0, aClass.lastIndexOf(".")));
// }
//
// return ret.toArray(new String[]{});
// }
| import com.github.javaparser.ParseException;
import com.highway2urhell.transformer.Struts1Transformer;
import org.junit.Test;
import java.io.FileNotFoundException;
import static com.highway2urhell.utils.ParsingUtil.extractBody;
import static com.highway2urhell.utils.ParsingUtil.extractPackages;
import static org.fest.assertions.Assertions.assertThat; | package com.highway2urhell.collector;
public class Struts1CollectorTest {
@Test
public void checkScript() throws FileNotFoundException, ParseException {
assertThat(Struts1Transformer.collectBody())
.isEqualTo(extractBody("./src/test/java/com/highway2urhell/collector/Struts1Collector.java", "collectBody"));
assertThat(Struts1Transformer.collectPackages()) | // Path: h2hell-core/src/main/java/com/highway2urhell/transformer/Struts1Transformer.java
// public class Struts1Transformer extends AbstractLeechTransformer {
//
// public Struts1Transformer() {
// super("org/apache/struts/action/ActionServlet");
// addImportPackage(collectPackages());
// }
//
// public static String[] collectPackages() {
// return new String[]{
// "com.highway2urhell",
// "com.highway2urhell.domain",
// "java.lang.reflect",
// "java.util",
// "org.apache.commons.digester",
// "org.apache.struts.action",
// "org.apache.struts.config.impl"
// };
// }
//
// @Override
// protected void doTransform(CtClass cc) throws Exception {
// CtMethod m = cc.getMethod("destroyConfigDigester", "()V");
// m.insertBefore(collectBody());
// }
//
// public static String collectBody() {
// return "{\n" +
// " ModuleConfigImpl m = (ModuleConfigImpl) configDigester.getRoot();\n" +
// " Field f;\n" +
// " List listEntryPath = new ArrayList();\n" +
// " try {\n" +
// " f = m.getClass().getDeclaredField(\"actionConfigList\");\n" +
// " f.setAccessible(true);\n" +
// " List res = (ArrayList) f.get(m);\n" +
// " if (res != null) {\n" +
// " Iterator iter = res.iterator();\n" +
// " while (iter.hasNext()) {\n" +
// " ActionMapping action = (ActionMapping) iter.next();\n" +
// " if (action.getType() != null && !\"\".equals(action.getType())) {\n" +
// " try {\n" +
// " Class c = Class.forName(action.getType());\n" +
// " Method[] tabMet = c.getDeclaredMethods();\n" +
// " for (int i = 0; i < tabMet.length; i++) {\n" +
// " EntryPathData entry = new EntryPathData();\n" +
// " entry.setClassName(action.getType());\n" +
// " entry.setMethodName(tabMet[i].getName());\n" +
// " if (action.getPrefix() != null && !\"null\".equals(action.getPrefix())) {\n" +
// " entry.setUri(action.getPrefix() + action.getPath());\n" +
// " } else {\n" +
// " entry.setUri(action.getPath());\n" +
// " }\n" +
// " entry.setTypePath(TypePath.DYNAMIC);\n" +
// " List listEntryPathData = new ArrayList();\n" +
// " for (int j = 0; j < tabMet[i].getParameterTypes().length; j++) {\n" +
// " EntryPathParam param = new EntryPathParam();\n" +
// " param.setKey(\"\");\n" +
// " param.setTypeParam(TypeParam.PARAM_DATA);\n" +
// " param.setValue(tabMet[i].getParameterTypes()[j].getName());\n" +
// " listEntryPathData.add(param);\n" +
// " }\n" +
// " entry.setListEntryPathData(listEntryPathData);\n" +
// " entry.setSignatureName(org.objectweb.asm.Type.getMethodDescriptor(tabMet[i]));\n" +
// " listEntryPath.add(entry);\n" +
// " }\n" +
// " } catch (ClassNotFoundException e) {\n" +
// " e.printStackTrace();\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " } catch (Exception e) {\n" +
// " e.printStackTrace();\n" +
// " }\n" +
// " CoreEngine.getInstance().getFramework(\"STRUTS_1\").receiveData(listEntryPath);\n" +
// "}";
// }
// }
//
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String extractBody(String in, String methodName) throws ParseException, FileNotFoundException {
// return extractMethod(JavaParser.parse(new FileInputStream(in)), methodName);
// }
//
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String[] extractPackages(String in) throws ParseException, FileNotFoundException {
// List<String> classes = extractImports(in);
// Set<String> ret = new TreeSet<String>();
// for (String aClass : classes) {
// ret.add(aClass.substring(0, aClass.lastIndexOf(".")));
// }
//
// return ret.toArray(new String[]{});
// }
// Path: h2hell-core/src/test/java/com/highway2urhell/collector/Struts1CollectorTest.java
import com.github.javaparser.ParseException;
import com.highway2urhell.transformer.Struts1Transformer;
import org.junit.Test;
import java.io.FileNotFoundException;
import static com.highway2urhell.utils.ParsingUtil.extractBody;
import static com.highway2urhell.utils.ParsingUtil.extractPackages;
import static org.fest.assertions.Assertions.assertThat;
package com.highway2urhell.collector;
public class Struts1CollectorTest {
@Test
public void checkScript() throws FileNotFoundException, ParseException {
assertThat(Struts1Transformer.collectBody())
.isEqualTo(extractBody("./src/test/java/com/highway2urhell/collector/Struts1Collector.java", "collectBody"));
assertThat(Struts1Transformer.collectPackages()) | .isEqualTo(extractPackages("./src/test/java/com/highway2urhell/collector/Struts1Collector.java")); |
highway-to-urhell/highway-to-urhell | h2hell-core/src/main/java/com/highway2urhell/agent/H2hellAgent.java | // Path: h2hell-core/src/main/java/com/highway2urhell/PluginUtils.java
// public class PluginUtils {
//
// private PluginUtils() {
// }
//
// public static <T> Set<T> autodiscoverPlugin(Class<T> pluginClass) {
// Set pluginList = new HashSet();
// Reflections reflections = new Reflections("com.highway2urhell");
// Set<Class<? extends T>> pluginsAvailable = reflections.getSubTypesOf(pluginClass);
// for (Class<? extends T> plugin : pluginsAvailable) {
// try {
// System.out.println("registering "+pluginClass.getName()+" : "+ plugin.getCanonicalName());
// T instance = plugin.newInstance();
// pluginList.add(instance);
// } catch (InstantiationException e) {
// System.err.println("An error occurred while registering " + pluginClass.getName() + " : " + plugin.getCanonicalName()+ e);
// } catch (IllegalAccessException e) {
// System.err.println("An error occurred while registering " + pluginClass.getName() + " : " + plugin.getCanonicalName()+ e);
// }
// }
// return pluginList;
// }
// }
//
// Path: h2hell-core/src/main/java/com/highway2urhell/transformer/AbstractLeechTransformer.java
// public abstract class AbstractLeechTransformer implements ClassFileTransformer {
// private final String classNameToTransformNormalized;
// private final String classNameToTransform;
//
// private List<String> importPackages = new ArrayList<String>();
//
// public AbstractLeechTransformer(String classNameToTransform) {
// this.classNameToTransform = classNameToTransform;
// this.classNameToTransformNormalized = classNameToTransform.replace("/", ".");
// addImportPackage(
// "com.highway2urhell",
// "com.highway2urhell.domain",
// "com.highway2urhell.service",
// "com.highway2urhell.transformer");
// }
//
// protected void addImportPackage(String... packages) {
// addImportPackage(Arrays.asList(packages));
// }
//
// protected void addImportPackage(Iterable<String> packages) {
// for (String packageName : packages) {
// this.importPackages.add(packageName);
// }
// }
//
// public byte[] transform(ClassLoader loader, String className,
// Class<?> classBeingRedefined, ProtectionDomain protectionDomain,
// byte[] classfileBuffer) throws IllegalClassFormatException {
// if (className.equals(classNameToTransform)) {
// System.out.println("Going to Transform "+classNameToTransform+ this.getClass());
// try {
// ClassPool cp = ClassPool.getDefault();
// cp.insertClassPath(new LoaderClassPath(loader));
// for (String importPackage : importPackages) {
// cp.importPackage(importPackage);
// }
// CtClass cc = cp.get(classNameToTransformNormalized);
// grabAllMethod(cc);
//
// doTransform(cc);
//
// classfileBuffer = cc.toBytecode();
// cc.detach();
//
// } catch (NotFoundException ex) {
// System.err.println("not found "+ ex);
// } catch (Exception ex) {
// System.err.println("Fail to Transform " +classNameToTransform+"with : "+this.getClass()+ ex);
// }
// }
//
// return classfileBuffer;
// }
//
// private void grabAllMethod(CtClass cc) {
// for (CtMethod method : cc.getMethods()) {
// System.err.println(method.getLongName() + "-" + method.getSignature() + " at line " + method.getMethodInfo().getLineNumber(0));
// try {
// method.instrument(
// new ExprEditor() {
// public void edit(MethodCall m) throws CannotCompileException {
// System.err.println("method invoke into the method observe "+m.getClassName() + "." + m.getMethodName() + " " + m.getSignature());
// }
// });
// } catch (CannotCompileException e) {
// System.err.println("Cannot Compil Exception"+e.getMessage());
// }
//
// }
// for (CtConstructor c : cc.getConstructors()) {
// System.err.println(c.getLongName() + "-" + c.getSignature()+" at line "+c.getMethodInfo().getLineNumber(0));
// }
//
// }
//
// /**
// * Build receiveDataStatement to be produced by transformer where you want to collectdata
// *
// * @param frameworkName a given frameworkname to invoke
// * @param dataToCollect statement representing data
// * @return produced statement
// */
// public String buildReceiveDataStatement(String frameworkName, String dataToCollect) {
// return "CoreEngine.getInstance().getFramework(\"" + frameworkName + "\").receiveData(" + dataToCollect + ");";
// }
//
// protected abstract void doTransform(CtClass cc) throws Exception;
// }
| import com.highway2urhell.PluginUtils;
import com.highway2urhell.transformer.AbstractLeechTransformer;
import java.io.File;
import java.lang.instrument.Instrumentation;
import java.lang.reflect.Method;
import java.net.URI;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.List; | package com.highway2urhell.agent;
public class H2hellAgent {
public static void premain(String agentArgs, Instrumentation inst) {
// Hack for load Jar
findJarAndLoadIfNecessary(); | // Path: h2hell-core/src/main/java/com/highway2urhell/PluginUtils.java
// public class PluginUtils {
//
// private PluginUtils() {
// }
//
// public static <T> Set<T> autodiscoverPlugin(Class<T> pluginClass) {
// Set pluginList = new HashSet();
// Reflections reflections = new Reflections("com.highway2urhell");
// Set<Class<? extends T>> pluginsAvailable = reflections.getSubTypesOf(pluginClass);
// for (Class<? extends T> plugin : pluginsAvailable) {
// try {
// System.out.println("registering "+pluginClass.getName()+" : "+ plugin.getCanonicalName());
// T instance = plugin.newInstance();
// pluginList.add(instance);
// } catch (InstantiationException e) {
// System.err.println("An error occurred while registering " + pluginClass.getName() + " : " + plugin.getCanonicalName()+ e);
// } catch (IllegalAccessException e) {
// System.err.println("An error occurred while registering " + pluginClass.getName() + " : " + plugin.getCanonicalName()+ e);
// }
// }
// return pluginList;
// }
// }
//
// Path: h2hell-core/src/main/java/com/highway2urhell/transformer/AbstractLeechTransformer.java
// public abstract class AbstractLeechTransformer implements ClassFileTransformer {
// private final String classNameToTransformNormalized;
// private final String classNameToTransform;
//
// private List<String> importPackages = new ArrayList<String>();
//
// public AbstractLeechTransformer(String classNameToTransform) {
// this.classNameToTransform = classNameToTransform;
// this.classNameToTransformNormalized = classNameToTransform.replace("/", ".");
// addImportPackage(
// "com.highway2urhell",
// "com.highway2urhell.domain",
// "com.highway2urhell.service",
// "com.highway2urhell.transformer");
// }
//
// protected void addImportPackage(String... packages) {
// addImportPackage(Arrays.asList(packages));
// }
//
// protected void addImportPackage(Iterable<String> packages) {
// for (String packageName : packages) {
// this.importPackages.add(packageName);
// }
// }
//
// public byte[] transform(ClassLoader loader, String className,
// Class<?> classBeingRedefined, ProtectionDomain protectionDomain,
// byte[] classfileBuffer) throws IllegalClassFormatException {
// if (className.equals(classNameToTransform)) {
// System.out.println("Going to Transform "+classNameToTransform+ this.getClass());
// try {
// ClassPool cp = ClassPool.getDefault();
// cp.insertClassPath(new LoaderClassPath(loader));
// for (String importPackage : importPackages) {
// cp.importPackage(importPackage);
// }
// CtClass cc = cp.get(classNameToTransformNormalized);
// grabAllMethod(cc);
//
// doTransform(cc);
//
// classfileBuffer = cc.toBytecode();
// cc.detach();
//
// } catch (NotFoundException ex) {
// System.err.println("not found "+ ex);
// } catch (Exception ex) {
// System.err.println("Fail to Transform " +classNameToTransform+"with : "+this.getClass()+ ex);
// }
// }
//
// return classfileBuffer;
// }
//
// private void grabAllMethod(CtClass cc) {
// for (CtMethod method : cc.getMethods()) {
// System.err.println(method.getLongName() + "-" + method.getSignature() + " at line " + method.getMethodInfo().getLineNumber(0));
// try {
// method.instrument(
// new ExprEditor() {
// public void edit(MethodCall m) throws CannotCompileException {
// System.err.println("method invoke into the method observe "+m.getClassName() + "." + m.getMethodName() + " " + m.getSignature());
// }
// });
// } catch (CannotCompileException e) {
// System.err.println("Cannot Compil Exception"+e.getMessage());
// }
//
// }
// for (CtConstructor c : cc.getConstructors()) {
// System.err.println(c.getLongName() + "-" + c.getSignature()+" at line "+c.getMethodInfo().getLineNumber(0));
// }
//
// }
//
// /**
// * Build receiveDataStatement to be produced by transformer where you want to collectdata
// *
// * @param frameworkName a given frameworkname to invoke
// * @param dataToCollect statement representing data
// * @return produced statement
// */
// public String buildReceiveDataStatement(String frameworkName, String dataToCollect) {
// return "CoreEngine.getInstance().getFramework(\"" + frameworkName + "\").receiveData(" + dataToCollect + ");";
// }
//
// protected abstract void doTransform(CtClass cc) throws Exception;
// }
// Path: h2hell-core/src/main/java/com/highway2urhell/agent/H2hellAgent.java
import com.highway2urhell.PluginUtils;
import com.highway2urhell.transformer.AbstractLeechTransformer;
import java.io.File;
import java.lang.instrument.Instrumentation;
import java.lang.reflect.Method;
import java.net.URI;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.List;
package com.highway2urhell.agent;
public class H2hellAgent {
public static void premain(String agentArgs, Instrumentation inst) {
// Hack for load Jar
findJarAndLoadIfNecessary(); | for (AbstractLeechTransformer transformer : PluginUtils.autodiscoverPlugin(AbstractLeechTransformer.class)) { |
highway-to-urhell/highway-to-urhell | h2hell-core/src/main/java/com/highway2urhell/agent/H2hellAgent.java | // Path: h2hell-core/src/main/java/com/highway2urhell/PluginUtils.java
// public class PluginUtils {
//
// private PluginUtils() {
// }
//
// public static <T> Set<T> autodiscoverPlugin(Class<T> pluginClass) {
// Set pluginList = new HashSet();
// Reflections reflections = new Reflections("com.highway2urhell");
// Set<Class<? extends T>> pluginsAvailable = reflections.getSubTypesOf(pluginClass);
// for (Class<? extends T> plugin : pluginsAvailable) {
// try {
// System.out.println("registering "+pluginClass.getName()+" : "+ plugin.getCanonicalName());
// T instance = plugin.newInstance();
// pluginList.add(instance);
// } catch (InstantiationException e) {
// System.err.println("An error occurred while registering " + pluginClass.getName() + " : " + plugin.getCanonicalName()+ e);
// } catch (IllegalAccessException e) {
// System.err.println("An error occurred while registering " + pluginClass.getName() + " : " + plugin.getCanonicalName()+ e);
// }
// }
// return pluginList;
// }
// }
//
// Path: h2hell-core/src/main/java/com/highway2urhell/transformer/AbstractLeechTransformer.java
// public abstract class AbstractLeechTransformer implements ClassFileTransformer {
// private final String classNameToTransformNormalized;
// private final String classNameToTransform;
//
// private List<String> importPackages = new ArrayList<String>();
//
// public AbstractLeechTransformer(String classNameToTransform) {
// this.classNameToTransform = classNameToTransform;
// this.classNameToTransformNormalized = classNameToTransform.replace("/", ".");
// addImportPackage(
// "com.highway2urhell",
// "com.highway2urhell.domain",
// "com.highway2urhell.service",
// "com.highway2urhell.transformer");
// }
//
// protected void addImportPackage(String... packages) {
// addImportPackage(Arrays.asList(packages));
// }
//
// protected void addImportPackage(Iterable<String> packages) {
// for (String packageName : packages) {
// this.importPackages.add(packageName);
// }
// }
//
// public byte[] transform(ClassLoader loader, String className,
// Class<?> classBeingRedefined, ProtectionDomain protectionDomain,
// byte[] classfileBuffer) throws IllegalClassFormatException {
// if (className.equals(classNameToTransform)) {
// System.out.println("Going to Transform "+classNameToTransform+ this.getClass());
// try {
// ClassPool cp = ClassPool.getDefault();
// cp.insertClassPath(new LoaderClassPath(loader));
// for (String importPackage : importPackages) {
// cp.importPackage(importPackage);
// }
// CtClass cc = cp.get(classNameToTransformNormalized);
// grabAllMethod(cc);
//
// doTransform(cc);
//
// classfileBuffer = cc.toBytecode();
// cc.detach();
//
// } catch (NotFoundException ex) {
// System.err.println("not found "+ ex);
// } catch (Exception ex) {
// System.err.println("Fail to Transform " +classNameToTransform+"with : "+this.getClass()+ ex);
// }
// }
//
// return classfileBuffer;
// }
//
// private void grabAllMethod(CtClass cc) {
// for (CtMethod method : cc.getMethods()) {
// System.err.println(method.getLongName() + "-" + method.getSignature() + " at line " + method.getMethodInfo().getLineNumber(0));
// try {
// method.instrument(
// new ExprEditor() {
// public void edit(MethodCall m) throws CannotCompileException {
// System.err.println("method invoke into the method observe "+m.getClassName() + "." + m.getMethodName() + " " + m.getSignature());
// }
// });
// } catch (CannotCompileException e) {
// System.err.println("Cannot Compil Exception"+e.getMessage());
// }
//
// }
// for (CtConstructor c : cc.getConstructors()) {
// System.err.println(c.getLongName() + "-" + c.getSignature()+" at line "+c.getMethodInfo().getLineNumber(0));
// }
//
// }
//
// /**
// * Build receiveDataStatement to be produced by transformer where you want to collectdata
// *
// * @param frameworkName a given frameworkname to invoke
// * @param dataToCollect statement representing data
// * @return produced statement
// */
// public String buildReceiveDataStatement(String frameworkName, String dataToCollect) {
// return "CoreEngine.getInstance().getFramework(\"" + frameworkName + "\").receiveData(" + dataToCollect + ");";
// }
//
// protected abstract void doTransform(CtClass cc) throws Exception;
// }
| import com.highway2urhell.PluginUtils;
import com.highway2urhell.transformer.AbstractLeechTransformer;
import java.io.File;
import java.lang.instrument.Instrumentation;
import java.lang.reflect.Method;
import java.net.URI;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.List; | package com.highway2urhell.agent;
public class H2hellAgent {
public static void premain(String agentArgs, Instrumentation inst) {
// Hack for load Jar
findJarAndLoadIfNecessary(); | // Path: h2hell-core/src/main/java/com/highway2urhell/PluginUtils.java
// public class PluginUtils {
//
// private PluginUtils() {
// }
//
// public static <T> Set<T> autodiscoverPlugin(Class<T> pluginClass) {
// Set pluginList = new HashSet();
// Reflections reflections = new Reflections("com.highway2urhell");
// Set<Class<? extends T>> pluginsAvailable = reflections.getSubTypesOf(pluginClass);
// for (Class<? extends T> plugin : pluginsAvailable) {
// try {
// System.out.println("registering "+pluginClass.getName()+" : "+ plugin.getCanonicalName());
// T instance = plugin.newInstance();
// pluginList.add(instance);
// } catch (InstantiationException e) {
// System.err.println("An error occurred while registering " + pluginClass.getName() + " : " + plugin.getCanonicalName()+ e);
// } catch (IllegalAccessException e) {
// System.err.println("An error occurred while registering " + pluginClass.getName() + " : " + plugin.getCanonicalName()+ e);
// }
// }
// return pluginList;
// }
// }
//
// Path: h2hell-core/src/main/java/com/highway2urhell/transformer/AbstractLeechTransformer.java
// public abstract class AbstractLeechTransformer implements ClassFileTransformer {
// private final String classNameToTransformNormalized;
// private final String classNameToTransform;
//
// private List<String> importPackages = new ArrayList<String>();
//
// public AbstractLeechTransformer(String classNameToTransform) {
// this.classNameToTransform = classNameToTransform;
// this.classNameToTransformNormalized = classNameToTransform.replace("/", ".");
// addImportPackage(
// "com.highway2urhell",
// "com.highway2urhell.domain",
// "com.highway2urhell.service",
// "com.highway2urhell.transformer");
// }
//
// protected void addImportPackage(String... packages) {
// addImportPackage(Arrays.asList(packages));
// }
//
// protected void addImportPackage(Iterable<String> packages) {
// for (String packageName : packages) {
// this.importPackages.add(packageName);
// }
// }
//
// public byte[] transform(ClassLoader loader, String className,
// Class<?> classBeingRedefined, ProtectionDomain protectionDomain,
// byte[] classfileBuffer) throws IllegalClassFormatException {
// if (className.equals(classNameToTransform)) {
// System.out.println("Going to Transform "+classNameToTransform+ this.getClass());
// try {
// ClassPool cp = ClassPool.getDefault();
// cp.insertClassPath(new LoaderClassPath(loader));
// for (String importPackage : importPackages) {
// cp.importPackage(importPackage);
// }
// CtClass cc = cp.get(classNameToTransformNormalized);
// grabAllMethod(cc);
//
// doTransform(cc);
//
// classfileBuffer = cc.toBytecode();
// cc.detach();
//
// } catch (NotFoundException ex) {
// System.err.println("not found "+ ex);
// } catch (Exception ex) {
// System.err.println("Fail to Transform " +classNameToTransform+"with : "+this.getClass()+ ex);
// }
// }
//
// return classfileBuffer;
// }
//
// private void grabAllMethod(CtClass cc) {
// for (CtMethod method : cc.getMethods()) {
// System.err.println(method.getLongName() + "-" + method.getSignature() + " at line " + method.getMethodInfo().getLineNumber(0));
// try {
// method.instrument(
// new ExprEditor() {
// public void edit(MethodCall m) throws CannotCompileException {
// System.err.println("method invoke into the method observe "+m.getClassName() + "." + m.getMethodName() + " " + m.getSignature());
// }
// });
// } catch (CannotCompileException e) {
// System.err.println("Cannot Compil Exception"+e.getMessage());
// }
//
// }
// for (CtConstructor c : cc.getConstructors()) {
// System.err.println(c.getLongName() + "-" + c.getSignature()+" at line "+c.getMethodInfo().getLineNumber(0));
// }
//
// }
//
// /**
// * Build receiveDataStatement to be produced by transformer where you want to collectdata
// *
// * @param frameworkName a given frameworkname to invoke
// * @param dataToCollect statement representing data
// * @return produced statement
// */
// public String buildReceiveDataStatement(String frameworkName, String dataToCollect) {
// return "CoreEngine.getInstance().getFramework(\"" + frameworkName + "\").receiveData(" + dataToCollect + ");";
// }
//
// protected abstract void doTransform(CtClass cc) throws Exception;
// }
// Path: h2hell-core/src/main/java/com/highway2urhell/agent/H2hellAgent.java
import com.highway2urhell.PluginUtils;
import com.highway2urhell.transformer.AbstractLeechTransformer;
import java.io.File;
import java.lang.instrument.Instrumentation;
import java.lang.reflect.Method;
import java.net.URI;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.List;
package com.highway2urhell.agent;
public class H2hellAgent {
public static void premain(String agentArgs, Instrumentation inst) {
// Hack for load Jar
findJarAndLoadIfNecessary(); | for (AbstractLeechTransformer transformer : PluginUtils.autodiscoverPlugin(AbstractLeechTransformer.class)) { |
highway-to-urhell/highway-to-urhell | h2hell-core/src/main/java/com/highway2urhell/service/TransformerService.java | // Path: h2hell-core/src/main/java/com/highway2urhell/domain/EntryPathData.java
// public class EntryPathData {
// private String uri;
// private String methodName;
// private String className;
// private String classNameNormalized;
// private String signatureName;
// private TypePath typePath = TypePath.UNKNOWN;
// private Boolean audit = true;
// private String httpMethod = "";
// private List<EntryPathParam> listEntryPathData = new ArrayList<EntryPathParam>();
// private Integer lineNumber;
//
// public Integer getLineNumber() {
// return lineNumber;
// }
//
// public void setLineNumber(Integer lineNumber) {
// this.lineNumber = lineNumber;
// }
//
// public Boolean getAudit() {
// return audit;
// }
//
// public void setAudit(Boolean audit) {
// this.audit = audit;
// }
//
// public String getUri() {
// return uri;
// }
//
// public void setUri(String uri) {
// this.uri = uri;
// }
//
// public String getMethodName() {
// return methodName;
// }
//
// public void setMethodName(String methodName) {
// this.methodName = methodName;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
//
// public String getClassNameNormalized() {
// return classNameNormalized;
// }
//
// public void setClassNameNormalized(String classNameNormalized) {
// this.classNameNormalized = classNameNormalized;
// }
//
// public String getSignatureName() {
// return signatureName;
// }
//
// public void setSignatureName(String signatureName) {
// this.signatureName = signatureName;
// }
//
// public TypePath getTypePath() {
// return typePath;
// }
//
// public void setTypePath(TypePath typePath) {
// this.typePath = typePath;
// }
//
// public String getHttpMethod() {
// return httpMethod;
// }
//
// public void setHttpMethod(String httpMethod) {
// this.httpMethod = httpMethod;
// }
//
// public List<EntryPathParam> getListEntryPathData() {
// return listEntryPathData;
// }
//
// public void setListEntryPathData(List<EntryPathParam> listEntryPathData) {
// this.listEntryPathData = listEntryPathData;
// }
//
// @Override
// public String toString() {
// return "EntryPathData [uri=" + uri + ", methodName=" + methodName
// + ", className=" + className + ", classNameNormalized="
// + classNameNormalized + ", signatureName=" + signatureName
// + ", typePath=" + typePath + ", httpMethod=" + httpMethod
// + "]";
// }
// }
//
// Path: h2hell-core/src/main/java/com/highway2urhell/domain/FilterEntryPath.java
// public class FilterEntryPath {
//
// private List<String> listFilter;
// private String token;
// private Boolean filter = false;
// private Boolean packageOnly = false;
// private Boolean classOnly = false;
// private Boolean classMethod = false;
//
// public List<String> getListFilter() {
// return listFilter;
// }
//
// public Boolean getClassOnly() {
// return classOnly;
// }
//
// public void setClassOnly(Boolean classOnly) {
// this.classOnly = classOnly;
// }
//
// public void setListFilter(List<String> listFilter) {
// this.listFilter = listFilter;
// }
//
// public String getToken() {
// return token;
// }
//
// public void setToken(String token) {
// this.token = token;
// }
//
// public Boolean getFilter() {
// return filter;
// }
//
// public void setFilter(Boolean filter) {
// this.filter = filter;
// }
//
// public Boolean getPackageOnly() {
// return packageOnly;
// }
//
// public void setPackageOnly(Boolean packageOnly) {
// this.packageOnly = packageOnly;
// }
//
// public Boolean getClassMethod() {
// return classMethod;
// }
//
// @Override
// public String toString() {
// return "FilterEntryPath{" +
// "listFilter=" + listFilter +
// ", token='" + token + '\'' +
// ", filter=" + filter +
// ", packageOnly=" + packageOnly +
// ", classOnly=" + classOnly +
// ", classMethod=" + classMethod +
// '}';
// }
//
// public void setClassMethod(Boolean classMethod) {
// this.classMethod = classMethod;
// }
// }
| import com.highway2urhell.domain.EntryPathData;
import com.highway2urhell.domain.FilterEntryPath;
import java.lang.instrument.Instrumentation;
import java.lang.instrument.UnmodifiableClassException;
import java.util.*; | package com.highway2urhell.service;
public class TransformerService {
public void transformAllClassScanByH2h(Instrumentation inst,
Set<String> entryClassName) {
for (String classNameNormalized : entryClassName) {
String className = classNameNormalized.replaceAll("/", ".");
System.err.println("Transform class "+ className);
transformOneClass(inst, className);
}
}
private void transformOneClass(Instrumentation inst, String className) {
ClassLoader classLoader = Thread.currentThread()
.getContextClassLoader();
try {
inst.retransformClasses(classLoader.loadClass(className));
} catch (ClassNotFoundException e) {
System.err.println("Error while transform Class"+className+" msg "+ e);
} catch (UnmodifiableClassException e) {
System.err.println("Error while transform Class"+className+" msg "+ e);
}
}
| // Path: h2hell-core/src/main/java/com/highway2urhell/domain/EntryPathData.java
// public class EntryPathData {
// private String uri;
// private String methodName;
// private String className;
// private String classNameNormalized;
// private String signatureName;
// private TypePath typePath = TypePath.UNKNOWN;
// private Boolean audit = true;
// private String httpMethod = "";
// private List<EntryPathParam> listEntryPathData = new ArrayList<EntryPathParam>();
// private Integer lineNumber;
//
// public Integer getLineNumber() {
// return lineNumber;
// }
//
// public void setLineNumber(Integer lineNumber) {
// this.lineNumber = lineNumber;
// }
//
// public Boolean getAudit() {
// return audit;
// }
//
// public void setAudit(Boolean audit) {
// this.audit = audit;
// }
//
// public String getUri() {
// return uri;
// }
//
// public void setUri(String uri) {
// this.uri = uri;
// }
//
// public String getMethodName() {
// return methodName;
// }
//
// public void setMethodName(String methodName) {
// this.methodName = methodName;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
//
// public String getClassNameNormalized() {
// return classNameNormalized;
// }
//
// public void setClassNameNormalized(String classNameNormalized) {
// this.classNameNormalized = classNameNormalized;
// }
//
// public String getSignatureName() {
// return signatureName;
// }
//
// public void setSignatureName(String signatureName) {
// this.signatureName = signatureName;
// }
//
// public TypePath getTypePath() {
// return typePath;
// }
//
// public void setTypePath(TypePath typePath) {
// this.typePath = typePath;
// }
//
// public String getHttpMethod() {
// return httpMethod;
// }
//
// public void setHttpMethod(String httpMethod) {
// this.httpMethod = httpMethod;
// }
//
// public List<EntryPathParam> getListEntryPathData() {
// return listEntryPathData;
// }
//
// public void setListEntryPathData(List<EntryPathParam> listEntryPathData) {
// this.listEntryPathData = listEntryPathData;
// }
//
// @Override
// public String toString() {
// return "EntryPathData [uri=" + uri + ", methodName=" + methodName
// + ", className=" + className + ", classNameNormalized="
// + classNameNormalized + ", signatureName=" + signatureName
// + ", typePath=" + typePath + ", httpMethod=" + httpMethod
// + "]";
// }
// }
//
// Path: h2hell-core/src/main/java/com/highway2urhell/domain/FilterEntryPath.java
// public class FilterEntryPath {
//
// private List<String> listFilter;
// private String token;
// private Boolean filter = false;
// private Boolean packageOnly = false;
// private Boolean classOnly = false;
// private Boolean classMethod = false;
//
// public List<String> getListFilter() {
// return listFilter;
// }
//
// public Boolean getClassOnly() {
// return classOnly;
// }
//
// public void setClassOnly(Boolean classOnly) {
// this.classOnly = classOnly;
// }
//
// public void setListFilter(List<String> listFilter) {
// this.listFilter = listFilter;
// }
//
// public String getToken() {
// return token;
// }
//
// public void setToken(String token) {
// this.token = token;
// }
//
// public Boolean getFilter() {
// return filter;
// }
//
// public void setFilter(Boolean filter) {
// this.filter = filter;
// }
//
// public Boolean getPackageOnly() {
// return packageOnly;
// }
//
// public void setPackageOnly(Boolean packageOnly) {
// this.packageOnly = packageOnly;
// }
//
// public Boolean getClassMethod() {
// return classMethod;
// }
//
// @Override
// public String toString() {
// return "FilterEntryPath{" +
// "listFilter=" + listFilter +
// ", token='" + token + '\'' +
// ", filter=" + filter +
// ", packageOnly=" + packageOnly +
// ", classOnly=" + classOnly +
// ", classMethod=" + classMethod +
// '}';
// }
//
// public void setClassMethod(Boolean classMethod) {
// this.classMethod = classMethod;
// }
// }
// Path: h2hell-core/src/main/java/com/highway2urhell/service/TransformerService.java
import com.highway2urhell.domain.EntryPathData;
import com.highway2urhell.domain.FilterEntryPath;
import java.lang.instrument.Instrumentation;
import java.lang.instrument.UnmodifiableClassException;
import java.util.*;
package com.highway2urhell.service;
public class TransformerService {
public void transformAllClassScanByH2h(Instrumentation inst,
Set<String> entryClassName) {
for (String classNameNormalized : entryClassName) {
String className = classNameNormalized.replaceAll("/", ".");
System.err.println("Transform class "+ className);
transformOneClass(inst, className);
}
}
private void transformOneClass(Instrumentation inst, String className) {
ClassLoader classLoader = Thread.currentThread()
.getContextClassLoader();
try {
inst.retransformClasses(classLoader.loadClass(className));
} catch (ClassNotFoundException e) {
System.err.println("Error while transform Class"+className+" msg "+ e);
} catch (UnmodifiableClassException e) {
System.err.println("Error while transform Class"+className+" msg "+ e);
}
}
| private Boolean filterEntry(FilterEntryPath filterEntryPath, EntryPathData entryPath) { |
highway-to-urhell/highway-to-urhell | h2hell-core/src/main/java/com/highway2urhell/service/TransformerService.java | // Path: h2hell-core/src/main/java/com/highway2urhell/domain/EntryPathData.java
// public class EntryPathData {
// private String uri;
// private String methodName;
// private String className;
// private String classNameNormalized;
// private String signatureName;
// private TypePath typePath = TypePath.UNKNOWN;
// private Boolean audit = true;
// private String httpMethod = "";
// private List<EntryPathParam> listEntryPathData = new ArrayList<EntryPathParam>();
// private Integer lineNumber;
//
// public Integer getLineNumber() {
// return lineNumber;
// }
//
// public void setLineNumber(Integer lineNumber) {
// this.lineNumber = lineNumber;
// }
//
// public Boolean getAudit() {
// return audit;
// }
//
// public void setAudit(Boolean audit) {
// this.audit = audit;
// }
//
// public String getUri() {
// return uri;
// }
//
// public void setUri(String uri) {
// this.uri = uri;
// }
//
// public String getMethodName() {
// return methodName;
// }
//
// public void setMethodName(String methodName) {
// this.methodName = methodName;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
//
// public String getClassNameNormalized() {
// return classNameNormalized;
// }
//
// public void setClassNameNormalized(String classNameNormalized) {
// this.classNameNormalized = classNameNormalized;
// }
//
// public String getSignatureName() {
// return signatureName;
// }
//
// public void setSignatureName(String signatureName) {
// this.signatureName = signatureName;
// }
//
// public TypePath getTypePath() {
// return typePath;
// }
//
// public void setTypePath(TypePath typePath) {
// this.typePath = typePath;
// }
//
// public String getHttpMethod() {
// return httpMethod;
// }
//
// public void setHttpMethod(String httpMethod) {
// this.httpMethod = httpMethod;
// }
//
// public List<EntryPathParam> getListEntryPathData() {
// return listEntryPathData;
// }
//
// public void setListEntryPathData(List<EntryPathParam> listEntryPathData) {
// this.listEntryPathData = listEntryPathData;
// }
//
// @Override
// public String toString() {
// return "EntryPathData [uri=" + uri + ", methodName=" + methodName
// + ", className=" + className + ", classNameNormalized="
// + classNameNormalized + ", signatureName=" + signatureName
// + ", typePath=" + typePath + ", httpMethod=" + httpMethod
// + "]";
// }
// }
//
// Path: h2hell-core/src/main/java/com/highway2urhell/domain/FilterEntryPath.java
// public class FilterEntryPath {
//
// private List<String> listFilter;
// private String token;
// private Boolean filter = false;
// private Boolean packageOnly = false;
// private Boolean classOnly = false;
// private Boolean classMethod = false;
//
// public List<String> getListFilter() {
// return listFilter;
// }
//
// public Boolean getClassOnly() {
// return classOnly;
// }
//
// public void setClassOnly(Boolean classOnly) {
// this.classOnly = classOnly;
// }
//
// public void setListFilter(List<String> listFilter) {
// this.listFilter = listFilter;
// }
//
// public String getToken() {
// return token;
// }
//
// public void setToken(String token) {
// this.token = token;
// }
//
// public Boolean getFilter() {
// return filter;
// }
//
// public void setFilter(Boolean filter) {
// this.filter = filter;
// }
//
// public Boolean getPackageOnly() {
// return packageOnly;
// }
//
// public void setPackageOnly(Boolean packageOnly) {
// this.packageOnly = packageOnly;
// }
//
// public Boolean getClassMethod() {
// return classMethod;
// }
//
// @Override
// public String toString() {
// return "FilterEntryPath{" +
// "listFilter=" + listFilter +
// ", token='" + token + '\'' +
// ", filter=" + filter +
// ", packageOnly=" + packageOnly +
// ", classOnly=" + classOnly +
// ", classMethod=" + classMethod +
// '}';
// }
//
// public void setClassMethod(Boolean classMethod) {
// this.classMethod = classMethod;
// }
// }
| import com.highway2urhell.domain.EntryPathData;
import com.highway2urhell.domain.FilterEntryPath;
import java.lang.instrument.Instrumentation;
import java.lang.instrument.UnmodifiableClassException;
import java.util.*; | package com.highway2urhell.service;
public class TransformerService {
public void transformAllClassScanByH2h(Instrumentation inst,
Set<String> entryClassName) {
for (String classNameNormalized : entryClassName) {
String className = classNameNormalized.replaceAll("/", ".");
System.err.println("Transform class "+ className);
transformOneClass(inst, className);
}
}
private void transformOneClass(Instrumentation inst, String className) {
ClassLoader classLoader = Thread.currentThread()
.getContextClassLoader();
try {
inst.retransformClasses(classLoader.loadClass(className));
} catch (ClassNotFoundException e) {
System.err.println("Error while transform Class"+className+" msg "+ e);
} catch (UnmodifiableClassException e) {
System.err.println("Error while transform Class"+className+" msg "+ e);
}
}
| // Path: h2hell-core/src/main/java/com/highway2urhell/domain/EntryPathData.java
// public class EntryPathData {
// private String uri;
// private String methodName;
// private String className;
// private String classNameNormalized;
// private String signatureName;
// private TypePath typePath = TypePath.UNKNOWN;
// private Boolean audit = true;
// private String httpMethod = "";
// private List<EntryPathParam> listEntryPathData = new ArrayList<EntryPathParam>();
// private Integer lineNumber;
//
// public Integer getLineNumber() {
// return lineNumber;
// }
//
// public void setLineNumber(Integer lineNumber) {
// this.lineNumber = lineNumber;
// }
//
// public Boolean getAudit() {
// return audit;
// }
//
// public void setAudit(Boolean audit) {
// this.audit = audit;
// }
//
// public String getUri() {
// return uri;
// }
//
// public void setUri(String uri) {
// this.uri = uri;
// }
//
// public String getMethodName() {
// return methodName;
// }
//
// public void setMethodName(String methodName) {
// this.methodName = methodName;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
//
// public String getClassNameNormalized() {
// return classNameNormalized;
// }
//
// public void setClassNameNormalized(String classNameNormalized) {
// this.classNameNormalized = classNameNormalized;
// }
//
// public String getSignatureName() {
// return signatureName;
// }
//
// public void setSignatureName(String signatureName) {
// this.signatureName = signatureName;
// }
//
// public TypePath getTypePath() {
// return typePath;
// }
//
// public void setTypePath(TypePath typePath) {
// this.typePath = typePath;
// }
//
// public String getHttpMethod() {
// return httpMethod;
// }
//
// public void setHttpMethod(String httpMethod) {
// this.httpMethod = httpMethod;
// }
//
// public List<EntryPathParam> getListEntryPathData() {
// return listEntryPathData;
// }
//
// public void setListEntryPathData(List<EntryPathParam> listEntryPathData) {
// this.listEntryPathData = listEntryPathData;
// }
//
// @Override
// public String toString() {
// return "EntryPathData [uri=" + uri + ", methodName=" + methodName
// + ", className=" + className + ", classNameNormalized="
// + classNameNormalized + ", signatureName=" + signatureName
// + ", typePath=" + typePath + ", httpMethod=" + httpMethod
// + "]";
// }
// }
//
// Path: h2hell-core/src/main/java/com/highway2urhell/domain/FilterEntryPath.java
// public class FilterEntryPath {
//
// private List<String> listFilter;
// private String token;
// private Boolean filter = false;
// private Boolean packageOnly = false;
// private Boolean classOnly = false;
// private Boolean classMethod = false;
//
// public List<String> getListFilter() {
// return listFilter;
// }
//
// public Boolean getClassOnly() {
// return classOnly;
// }
//
// public void setClassOnly(Boolean classOnly) {
// this.classOnly = classOnly;
// }
//
// public void setListFilter(List<String> listFilter) {
// this.listFilter = listFilter;
// }
//
// public String getToken() {
// return token;
// }
//
// public void setToken(String token) {
// this.token = token;
// }
//
// public Boolean getFilter() {
// return filter;
// }
//
// public void setFilter(Boolean filter) {
// this.filter = filter;
// }
//
// public Boolean getPackageOnly() {
// return packageOnly;
// }
//
// public void setPackageOnly(Boolean packageOnly) {
// this.packageOnly = packageOnly;
// }
//
// public Boolean getClassMethod() {
// return classMethod;
// }
//
// @Override
// public String toString() {
// return "FilterEntryPath{" +
// "listFilter=" + listFilter +
// ", token='" + token + '\'' +
// ", filter=" + filter +
// ", packageOnly=" + packageOnly +
// ", classOnly=" + classOnly +
// ", classMethod=" + classMethod +
// '}';
// }
//
// public void setClassMethod(Boolean classMethod) {
// this.classMethod = classMethod;
// }
// }
// Path: h2hell-core/src/main/java/com/highway2urhell/service/TransformerService.java
import com.highway2urhell.domain.EntryPathData;
import com.highway2urhell.domain.FilterEntryPath;
import java.lang.instrument.Instrumentation;
import java.lang.instrument.UnmodifiableClassException;
import java.util.*;
package com.highway2urhell.service;
public class TransformerService {
public void transformAllClassScanByH2h(Instrumentation inst,
Set<String> entryClassName) {
for (String classNameNormalized : entryClassName) {
String className = classNameNormalized.replaceAll("/", ".");
System.err.println("Transform class "+ className);
transformOneClass(inst, className);
}
}
private void transformOneClass(Instrumentation inst, String className) {
ClassLoader classLoader = Thread.currentThread()
.getContextClassLoader();
try {
inst.retransformClasses(classLoader.loadClass(className));
} catch (ClassNotFoundException e) {
System.err.println("Error while transform Class"+className+" msg "+ e);
} catch (UnmodifiableClassException e) {
System.err.println("Error while transform Class"+className+" msg "+ e);
}
}
| private Boolean filterEntry(FilterEntryPath filterEntryPath, EntryPathData entryPath) { |
highway-to-urhell/highway-to-urhell | h2hell-core/src/main/java/com/highway2urhell/service/impl/RmiService.java | // Path: h2hell-core/src/main/java/com/highway2urhell/domain/EntryPathData.java
// public class EntryPathData {
// private String uri;
// private String methodName;
// private String className;
// private String classNameNormalized;
// private String signatureName;
// private TypePath typePath = TypePath.UNKNOWN;
// private Boolean audit = true;
// private String httpMethod = "";
// private List<EntryPathParam> listEntryPathData = new ArrayList<EntryPathParam>();
// private Integer lineNumber;
//
// public Integer getLineNumber() {
// return lineNumber;
// }
//
// public void setLineNumber(Integer lineNumber) {
// this.lineNumber = lineNumber;
// }
//
// public Boolean getAudit() {
// return audit;
// }
//
// public void setAudit(Boolean audit) {
// this.audit = audit;
// }
//
// public String getUri() {
// return uri;
// }
//
// public void setUri(String uri) {
// this.uri = uri;
// }
//
// public String getMethodName() {
// return methodName;
// }
//
// public void setMethodName(String methodName) {
// this.methodName = methodName;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
//
// public String getClassNameNormalized() {
// return classNameNormalized;
// }
//
// public void setClassNameNormalized(String classNameNormalized) {
// this.classNameNormalized = classNameNormalized;
// }
//
// public String getSignatureName() {
// return signatureName;
// }
//
// public void setSignatureName(String signatureName) {
// this.signatureName = signatureName;
// }
//
// public TypePath getTypePath() {
// return typePath;
// }
//
// public void setTypePath(TypePath typePath) {
// this.typePath = typePath;
// }
//
// public String getHttpMethod() {
// return httpMethod;
// }
//
// public void setHttpMethod(String httpMethod) {
// this.httpMethod = httpMethod;
// }
//
// public List<EntryPathParam> getListEntryPathData() {
// return listEntryPathData;
// }
//
// public void setListEntryPathData(List<EntryPathParam> listEntryPathData) {
// this.listEntryPathData = listEntryPathData;
// }
//
// @Override
// public String toString() {
// return "EntryPathData [uri=" + uri + ", methodName=" + methodName
// + ", className=" + className + ", classNameNormalized="
// + classNameNormalized + ", signatureName=" + signatureName
// + ", typePath=" + typePath + ", httpMethod=" + httpMethod
// + "]";
// }
// }
//
// Path: h2hell-core/src/main/java/com/highway2urhell/service/AbstractLeechService.java
// public abstract class AbstractLeechService implements LeechService {
//
// private FrameworkInformations frameworkInformations = new FrameworkInformations();
// private boolean triggeredAtStartup = false;
//
// public AbstractLeechService(String frameworkName) {
// frameworkInformations.setFrameworkName(frameworkName);
// }
//
// public AbstractLeechService(String frameworkName, String version) {
// this(frameworkName);
// frameworkInformations.setVersion(version);
// }
//
// @Override
// public boolean isTriggeredAtStartup() {
// return triggeredAtStartup;
// }
//
// protected void setTriggerAtStartup(boolean triggeredAtStartup) {
// this.triggeredAtStartup = triggeredAtStartup;
// }
//
// public void receiveData(List<EntryPathData> incoming) {
// clearPreviousData();
// System.out.println("receive incoming data obj "+ incoming+ "for framework "+frameworkInformations.getFrameworkName());
// gatherData(incoming);
// System.out.println("data gathering complete. Found entries "+frameworkInformations.getListEntryPath().size());
// }
//
// private void clearPreviousData() {
// frameworkInformations.getListEntryPath().clear();
// }
//
//
// protected void gatherData(List<EntryPathData> incoming) {
// List<EntryPathData> listEntryPath = incoming;
// for (EntryPathData entry : listEntryPath) {
// if (entry.getMethodName() != null && !entry.getMethodName().contains("$")) {
// addEntryPath(entry);
// }
// }
// }
//
// @Override
// public FrameworkInformations getFrameworkInformations() {
// return frameworkInformations;
// }
//
// protected void addEntryPath(EntryPathData entryPath) {
// frameworkInformations.getListEntryPath().add(entryPath);
// }
//
// public String getInternalSignature(String className, String methodName) {
// String res = "";
// try {
// Class<?> c = Class.forName(className);
// for (Method m : c.getDeclaredMethods()) {
// if (m.getName().equals(methodName)) {
// res = Type.getMethodDescriptor(m);
// }
// }
//
// } catch (ClassNotFoundException e) {
// System.err.println("Can't construct classname " + className+" : "+ e);
// }
//
// return res;
// }
//
// public String getInternalSignature(Method m) {
// return Type.getMethodDescriptor(m);
// }
// }
| import com.highway2urhell.domain.EntryPathData;
import com.highway2urhell.service.AbstractLeechService;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.List; | package com.highway2urhell.service.impl;
public class RmiService extends AbstractLeechService {
public static final String FRAMEWORK_NAME = "RMI";
public RmiService() {
super(FRAMEWORK_NAME);
}
@Override | // Path: h2hell-core/src/main/java/com/highway2urhell/domain/EntryPathData.java
// public class EntryPathData {
// private String uri;
// private String methodName;
// private String className;
// private String classNameNormalized;
// private String signatureName;
// private TypePath typePath = TypePath.UNKNOWN;
// private Boolean audit = true;
// private String httpMethod = "";
// private List<EntryPathParam> listEntryPathData = new ArrayList<EntryPathParam>();
// private Integer lineNumber;
//
// public Integer getLineNumber() {
// return lineNumber;
// }
//
// public void setLineNumber(Integer lineNumber) {
// this.lineNumber = lineNumber;
// }
//
// public Boolean getAudit() {
// return audit;
// }
//
// public void setAudit(Boolean audit) {
// this.audit = audit;
// }
//
// public String getUri() {
// return uri;
// }
//
// public void setUri(String uri) {
// this.uri = uri;
// }
//
// public String getMethodName() {
// return methodName;
// }
//
// public void setMethodName(String methodName) {
// this.methodName = methodName;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
//
// public String getClassNameNormalized() {
// return classNameNormalized;
// }
//
// public void setClassNameNormalized(String classNameNormalized) {
// this.classNameNormalized = classNameNormalized;
// }
//
// public String getSignatureName() {
// return signatureName;
// }
//
// public void setSignatureName(String signatureName) {
// this.signatureName = signatureName;
// }
//
// public TypePath getTypePath() {
// return typePath;
// }
//
// public void setTypePath(TypePath typePath) {
// this.typePath = typePath;
// }
//
// public String getHttpMethod() {
// return httpMethod;
// }
//
// public void setHttpMethod(String httpMethod) {
// this.httpMethod = httpMethod;
// }
//
// public List<EntryPathParam> getListEntryPathData() {
// return listEntryPathData;
// }
//
// public void setListEntryPathData(List<EntryPathParam> listEntryPathData) {
// this.listEntryPathData = listEntryPathData;
// }
//
// @Override
// public String toString() {
// return "EntryPathData [uri=" + uri + ", methodName=" + methodName
// + ", className=" + className + ", classNameNormalized="
// + classNameNormalized + ", signatureName=" + signatureName
// + ", typePath=" + typePath + ", httpMethod=" + httpMethod
// + "]";
// }
// }
//
// Path: h2hell-core/src/main/java/com/highway2urhell/service/AbstractLeechService.java
// public abstract class AbstractLeechService implements LeechService {
//
// private FrameworkInformations frameworkInformations = new FrameworkInformations();
// private boolean triggeredAtStartup = false;
//
// public AbstractLeechService(String frameworkName) {
// frameworkInformations.setFrameworkName(frameworkName);
// }
//
// public AbstractLeechService(String frameworkName, String version) {
// this(frameworkName);
// frameworkInformations.setVersion(version);
// }
//
// @Override
// public boolean isTriggeredAtStartup() {
// return triggeredAtStartup;
// }
//
// protected void setTriggerAtStartup(boolean triggeredAtStartup) {
// this.triggeredAtStartup = triggeredAtStartup;
// }
//
// public void receiveData(List<EntryPathData> incoming) {
// clearPreviousData();
// System.out.println("receive incoming data obj "+ incoming+ "for framework "+frameworkInformations.getFrameworkName());
// gatherData(incoming);
// System.out.println("data gathering complete. Found entries "+frameworkInformations.getListEntryPath().size());
// }
//
// private void clearPreviousData() {
// frameworkInformations.getListEntryPath().clear();
// }
//
//
// protected void gatherData(List<EntryPathData> incoming) {
// List<EntryPathData> listEntryPath = incoming;
// for (EntryPathData entry : listEntryPath) {
// if (entry.getMethodName() != null && !entry.getMethodName().contains("$")) {
// addEntryPath(entry);
// }
// }
// }
//
// @Override
// public FrameworkInformations getFrameworkInformations() {
// return frameworkInformations;
// }
//
// protected void addEntryPath(EntryPathData entryPath) {
// frameworkInformations.getListEntryPath().add(entryPath);
// }
//
// public String getInternalSignature(String className, String methodName) {
// String res = "";
// try {
// Class<?> c = Class.forName(className);
// for (Method m : c.getDeclaredMethods()) {
// if (m.getName().equals(methodName)) {
// res = Type.getMethodDescriptor(m);
// }
// }
//
// } catch (ClassNotFoundException e) {
// System.err.println("Can't construct classname " + className+" : "+ e);
// }
//
// return res;
// }
//
// public String getInternalSignature(Method m) {
// return Type.getMethodDescriptor(m);
// }
// }
// Path: h2hell-core/src/main/java/com/highway2urhell/service/impl/RmiService.java
import com.highway2urhell.domain.EntryPathData;
import com.highway2urhell.service.AbstractLeechService;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.List;
package com.highway2urhell.service.impl;
public class RmiService extends AbstractLeechService {
public static final String FRAMEWORK_NAME = "RMI";
public RmiService() {
super(FRAMEWORK_NAME);
}
@Override | protected void gatherData(List<EntryPathData> incoming) { |
highway-to-urhell/highway-to-urhell | h2hell-core/src/main/java/com/highway2urhell/service/AbstractLeechService.java | // Path: h2hell-core/src/main/java/com/highway2urhell/domain/EntryPathData.java
// public class EntryPathData {
// private String uri;
// private String methodName;
// private String className;
// private String classNameNormalized;
// private String signatureName;
// private TypePath typePath = TypePath.UNKNOWN;
// private Boolean audit = true;
// private String httpMethod = "";
// private List<EntryPathParam> listEntryPathData = new ArrayList<EntryPathParam>();
// private Integer lineNumber;
//
// public Integer getLineNumber() {
// return lineNumber;
// }
//
// public void setLineNumber(Integer lineNumber) {
// this.lineNumber = lineNumber;
// }
//
// public Boolean getAudit() {
// return audit;
// }
//
// public void setAudit(Boolean audit) {
// this.audit = audit;
// }
//
// public String getUri() {
// return uri;
// }
//
// public void setUri(String uri) {
// this.uri = uri;
// }
//
// public String getMethodName() {
// return methodName;
// }
//
// public void setMethodName(String methodName) {
// this.methodName = methodName;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
//
// public String getClassNameNormalized() {
// return classNameNormalized;
// }
//
// public void setClassNameNormalized(String classNameNormalized) {
// this.classNameNormalized = classNameNormalized;
// }
//
// public String getSignatureName() {
// return signatureName;
// }
//
// public void setSignatureName(String signatureName) {
// this.signatureName = signatureName;
// }
//
// public TypePath getTypePath() {
// return typePath;
// }
//
// public void setTypePath(TypePath typePath) {
// this.typePath = typePath;
// }
//
// public String getHttpMethod() {
// return httpMethod;
// }
//
// public void setHttpMethod(String httpMethod) {
// this.httpMethod = httpMethod;
// }
//
// public List<EntryPathParam> getListEntryPathData() {
// return listEntryPathData;
// }
//
// public void setListEntryPathData(List<EntryPathParam> listEntryPathData) {
// this.listEntryPathData = listEntryPathData;
// }
//
// @Override
// public String toString() {
// return "EntryPathData [uri=" + uri + ", methodName=" + methodName
// + ", className=" + className + ", classNameNormalized="
// + classNameNormalized + ", signatureName=" + signatureName
// + ", typePath=" + typePath + ", httpMethod=" + httpMethod
// + "]";
// }
// }
//
// Path: h2hell-core/src/main/java/com/highway2urhell/domain/FrameworkInformations.java
// public class FrameworkInformations {
//
// private String frameworkName;
// private String version = "UNKNOWN";
// private String details;
// private List<EntryPathData> listEntryPath = new ArrayList<EntryPathData>();
//
// public String getFrameworkName() {
// return frameworkName;
// }
//
// public void setFrameworkName(String frameworkName) {
// this.frameworkName = frameworkName;
// }
//
// public String getVersion() {
// return version;
// }
//
// public void setVersion(String version) {
// this.version = version;
// }
//
// public String getDetails() {
// return details;
// }
//
// public void setDetails(String details) {
// this.details = details;
// }
//
// public List<EntryPathData> getListEntryPath() {
// return listEntryPath;
// }
//
// public void setListEntryPath(List<EntryPathData> listEntryPath) {
// this.listEntryPath = listEntryPath;
// }
//
// public boolean hasEntryPaths() {
// return !listEntryPath.isEmpty();
// }
//
// @Override
// public String toString() {
// return "FrameworkInformations [frameworkName=" + frameworkName
// + ", version=" + version + ", details=" + details
// + ", listEntryPath=" + listEntryPath + "]";
// }
//
// }
| import com.highway2urhell.domain.EntryPathData;
import com.highway2urhell.domain.FrameworkInformations;
import org.objectweb.asm.Type;
import java.lang.reflect.Method;
import java.util.List; | package com.highway2urhell.service;
public abstract class AbstractLeechService implements LeechService {
private FrameworkInformations frameworkInformations = new FrameworkInformations();
private boolean triggeredAtStartup = false;
public AbstractLeechService(String frameworkName) {
frameworkInformations.setFrameworkName(frameworkName);
}
public AbstractLeechService(String frameworkName, String version) {
this(frameworkName);
frameworkInformations.setVersion(version);
}
@Override
public boolean isTriggeredAtStartup() {
return triggeredAtStartup;
}
protected void setTriggerAtStartup(boolean triggeredAtStartup) {
this.triggeredAtStartup = triggeredAtStartup;
}
| // Path: h2hell-core/src/main/java/com/highway2urhell/domain/EntryPathData.java
// public class EntryPathData {
// private String uri;
// private String methodName;
// private String className;
// private String classNameNormalized;
// private String signatureName;
// private TypePath typePath = TypePath.UNKNOWN;
// private Boolean audit = true;
// private String httpMethod = "";
// private List<EntryPathParam> listEntryPathData = new ArrayList<EntryPathParam>();
// private Integer lineNumber;
//
// public Integer getLineNumber() {
// return lineNumber;
// }
//
// public void setLineNumber(Integer lineNumber) {
// this.lineNumber = lineNumber;
// }
//
// public Boolean getAudit() {
// return audit;
// }
//
// public void setAudit(Boolean audit) {
// this.audit = audit;
// }
//
// public String getUri() {
// return uri;
// }
//
// public void setUri(String uri) {
// this.uri = uri;
// }
//
// public String getMethodName() {
// return methodName;
// }
//
// public void setMethodName(String methodName) {
// this.methodName = methodName;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
//
// public String getClassNameNormalized() {
// return classNameNormalized;
// }
//
// public void setClassNameNormalized(String classNameNormalized) {
// this.classNameNormalized = classNameNormalized;
// }
//
// public String getSignatureName() {
// return signatureName;
// }
//
// public void setSignatureName(String signatureName) {
// this.signatureName = signatureName;
// }
//
// public TypePath getTypePath() {
// return typePath;
// }
//
// public void setTypePath(TypePath typePath) {
// this.typePath = typePath;
// }
//
// public String getHttpMethod() {
// return httpMethod;
// }
//
// public void setHttpMethod(String httpMethod) {
// this.httpMethod = httpMethod;
// }
//
// public List<EntryPathParam> getListEntryPathData() {
// return listEntryPathData;
// }
//
// public void setListEntryPathData(List<EntryPathParam> listEntryPathData) {
// this.listEntryPathData = listEntryPathData;
// }
//
// @Override
// public String toString() {
// return "EntryPathData [uri=" + uri + ", methodName=" + methodName
// + ", className=" + className + ", classNameNormalized="
// + classNameNormalized + ", signatureName=" + signatureName
// + ", typePath=" + typePath + ", httpMethod=" + httpMethod
// + "]";
// }
// }
//
// Path: h2hell-core/src/main/java/com/highway2urhell/domain/FrameworkInformations.java
// public class FrameworkInformations {
//
// private String frameworkName;
// private String version = "UNKNOWN";
// private String details;
// private List<EntryPathData> listEntryPath = new ArrayList<EntryPathData>();
//
// public String getFrameworkName() {
// return frameworkName;
// }
//
// public void setFrameworkName(String frameworkName) {
// this.frameworkName = frameworkName;
// }
//
// public String getVersion() {
// return version;
// }
//
// public void setVersion(String version) {
// this.version = version;
// }
//
// public String getDetails() {
// return details;
// }
//
// public void setDetails(String details) {
// this.details = details;
// }
//
// public List<EntryPathData> getListEntryPath() {
// return listEntryPath;
// }
//
// public void setListEntryPath(List<EntryPathData> listEntryPath) {
// this.listEntryPath = listEntryPath;
// }
//
// public boolean hasEntryPaths() {
// return !listEntryPath.isEmpty();
// }
//
// @Override
// public String toString() {
// return "FrameworkInformations [frameworkName=" + frameworkName
// + ", version=" + version + ", details=" + details
// + ", listEntryPath=" + listEntryPath + "]";
// }
//
// }
// Path: h2hell-core/src/main/java/com/highway2urhell/service/AbstractLeechService.java
import com.highway2urhell.domain.EntryPathData;
import com.highway2urhell.domain.FrameworkInformations;
import org.objectweb.asm.Type;
import java.lang.reflect.Method;
import java.util.List;
package com.highway2urhell.service;
public abstract class AbstractLeechService implements LeechService {
private FrameworkInformations frameworkInformations = new FrameworkInformations();
private boolean triggeredAtStartup = false;
public AbstractLeechService(String frameworkName) {
frameworkInformations.setFrameworkName(frameworkName);
}
public AbstractLeechService(String frameworkName, String version) {
this(frameworkName);
frameworkInformations.setVersion(version);
}
@Override
public boolean isTriggeredAtStartup() {
return triggeredAtStartup;
}
protected void setTriggerAtStartup(boolean triggeredAtStartup) {
this.triggeredAtStartup = triggeredAtStartup;
}
| public void receiveData(List<EntryPathData> incoming) { |
highway-to-urhell/highway-to-urhell | h2hell-core/src/main/java/com/highway2urhell/service/impl/Struts1Service.java | // Path: h2hell-core/src/main/java/com/highway2urhell/VersionUtils.java
// public class VersionUtils {
//
// public static final String UNKNOWN_VERSION = "UNKNOWN";
// public static final String NO_FRAMEWORK = "NO_FRAMEWORK";
//
// private VersionUtils() {
// }
//
// public static String getVersion(String clazzName, String groupId, String artifactId) {
// //check
// Class<?> clazz;
// try {
// clazz = Class.forName(clazzName);
// } catch (ClassNotFoundException e1) {
// return NO_FRAMEWORK;
// }
// String version = null;
//
// // try to load from maven properties first
// Properties p = new Properties();
// InputStream is = null;
//
// try {
// is = clazz.getResourceAsStream("/META-INF/maven/" + groupId + "/" + artifactId + "/pom.properties");
// if (is != null) {
// p.load(is);
// version = p.getProperty("version", "");
// }
// } catch (Exception e) {
// // ignore
// } finally {
// if (is != null) {
// try {
// is.close();
// } catch (IOException e) {
// // ignore
// }
// }
// }
//
// // try to load from manifest
// try {
// URL clazzRes = clazz.getResource('/' + clazz.getName().replace('.', '/') + ".class");
// String classResPath = clazzRes.getPath();
// Manifest manifest = null;
// if (classResPath.contains("!")) {
// classResPath = classResPath.split("!")[0];
// URL url = new URL("jar:" + classResPath + "!/");
// JarURLConnection jarConnection = (JarURLConnection) url.openConnection();
// manifest = jarConnection.getManifest();
// } else {
// is = clazz.getResourceAsStream(classResPath + "!/META-INF/MANIFEST.MF");
// if (is != null)
// manifest = new Manifest(is);
//
// }
// if (manifest != null) {
// Attributes attr = manifest.getMainAttributes();
// version = attr.getValue("Implementation-Version");
// }
// } catch (Exception e) {
// // ignore
// } finally {
// if (is != null) {
// try {
// is.close();
// } catch (IOException e) {
// // ignore
// }
// }
// }
//
//
// // fallback to using Java API
// if (version == null) {
// Package aPackage = clazz.getPackage();
// if (aPackage != null) {
// version = aPackage.getImplementationVersion();
// if (version == null) {
// version = aPackage.getSpecificationVersion();
// }
// }
// }
// if (version == null) {
// // we could not compute the version so use a blank
// version = UNKNOWN_VERSION;
// }
//
// return version;
// }
//
// }
//
// Path: h2hell-core/src/main/java/com/highway2urhell/service/AbstractLeechService.java
// public abstract class AbstractLeechService implements LeechService {
//
// private FrameworkInformations frameworkInformations = new FrameworkInformations();
// private boolean triggeredAtStartup = false;
//
// public AbstractLeechService(String frameworkName) {
// frameworkInformations.setFrameworkName(frameworkName);
// }
//
// public AbstractLeechService(String frameworkName, String version) {
// this(frameworkName);
// frameworkInformations.setVersion(version);
// }
//
// @Override
// public boolean isTriggeredAtStartup() {
// return triggeredAtStartup;
// }
//
// protected void setTriggerAtStartup(boolean triggeredAtStartup) {
// this.triggeredAtStartup = triggeredAtStartup;
// }
//
// public void receiveData(List<EntryPathData> incoming) {
// clearPreviousData();
// System.out.println("receive incoming data obj "+ incoming+ "for framework "+frameworkInformations.getFrameworkName());
// gatherData(incoming);
// System.out.println("data gathering complete. Found entries "+frameworkInformations.getListEntryPath().size());
// }
//
// private void clearPreviousData() {
// frameworkInformations.getListEntryPath().clear();
// }
//
//
// protected void gatherData(List<EntryPathData> incoming) {
// List<EntryPathData> listEntryPath = incoming;
// for (EntryPathData entry : listEntryPath) {
// if (entry.getMethodName() != null && !entry.getMethodName().contains("$")) {
// addEntryPath(entry);
// }
// }
// }
//
// @Override
// public FrameworkInformations getFrameworkInformations() {
// return frameworkInformations;
// }
//
// protected void addEntryPath(EntryPathData entryPath) {
// frameworkInformations.getListEntryPath().add(entryPath);
// }
//
// public String getInternalSignature(String className, String methodName) {
// String res = "";
// try {
// Class<?> c = Class.forName(className);
// for (Method m : c.getDeclaredMethods()) {
// if (m.getName().equals(methodName)) {
// res = Type.getMethodDescriptor(m);
// }
// }
//
// } catch (ClassNotFoundException e) {
// System.err.println("Can't construct classname " + className+" : "+ e);
// }
//
// return res;
// }
//
// public String getInternalSignature(Method m) {
// return Type.getMethodDescriptor(m);
// }
// }
| import com.highway2urhell.VersionUtils;
import com.highway2urhell.service.AbstractLeechService; | package com.highway2urhell.service.impl;
public class Struts1Service extends AbstractLeechService {
public static final String FRAMEWORK_NAME = "STRUTS_1";
public Struts1Service() { | // Path: h2hell-core/src/main/java/com/highway2urhell/VersionUtils.java
// public class VersionUtils {
//
// public static final String UNKNOWN_VERSION = "UNKNOWN";
// public static final String NO_FRAMEWORK = "NO_FRAMEWORK";
//
// private VersionUtils() {
// }
//
// public static String getVersion(String clazzName, String groupId, String artifactId) {
// //check
// Class<?> clazz;
// try {
// clazz = Class.forName(clazzName);
// } catch (ClassNotFoundException e1) {
// return NO_FRAMEWORK;
// }
// String version = null;
//
// // try to load from maven properties first
// Properties p = new Properties();
// InputStream is = null;
//
// try {
// is = clazz.getResourceAsStream("/META-INF/maven/" + groupId + "/" + artifactId + "/pom.properties");
// if (is != null) {
// p.load(is);
// version = p.getProperty("version", "");
// }
// } catch (Exception e) {
// // ignore
// } finally {
// if (is != null) {
// try {
// is.close();
// } catch (IOException e) {
// // ignore
// }
// }
// }
//
// // try to load from manifest
// try {
// URL clazzRes = clazz.getResource('/' + clazz.getName().replace('.', '/') + ".class");
// String classResPath = clazzRes.getPath();
// Manifest manifest = null;
// if (classResPath.contains("!")) {
// classResPath = classResPath.split("!")[0];
// URL url = new URL("jar:" + classResPath + "!/");
// JarURLConnection jarConnection = (JarURLConnection) url.openConnection();
// manifest = jarConnection.getManifest();
// } else {
// is = clazz.getResourceAsStream(classResPath + "!/META-INF/MANIFEST.MF");
// if (is != null)
// manifest = new Manifest(is);
//
// }
// if (manifest != null) {
// Attributes attr = manifest.getMainAttributes();
// version = attr.getValue("Implementation-Version");
// }
// } catch (Exception e) {
// // ignore
// } finally {
// if (is != null) {
// try {
// is.close();
// } catch (IOException e) {
// // ignore
// }
// }
// }
//
//
// // fallback to using Java API
// if (version == null) {
// Package aPackage = clazz.getPackage();
// if (aPackage != null) {
// version = aPackage.getImplementationVersion();
// if (version == null) {
// version = aPackage.getSpecificationVersion();
// }
// }
// }
// if (version == null) {
// // we could not compute the version so use a blank
// version = UNKNOWN_VERSION;
// }
//
// return version;
// }
//
// }
//
// Path: h2hell-core/src/main/java/com/highway2urhell/service/AbstractLeechService.java
// public abstract class AbstractLeechService implements LeechService {
//
// private FrameworkInformations frameworkInformations = new FrameworkInformations();
// private boolean triggeredAtStartup = false;
//
// public AbstractLeechService(String frameworkName) {
// frameworkInformations.setFrameworkName(frameworkName);
// }
//
// public AbstractLeechService(String frameworkName, String version) {
// this(frameworkName);
// frameworkInformations.setVersion(version);
// }
//
// @Override
// public boolean isTriggeredAtStartup() {
// return triggeredAtStartup;
// }
//
// protected void setTriggerAtStartup(boolean triggeredAtStartup) {
// this.triggeredAtStartup = triggeredAtStartup;
// }
//
// public void receiveData(List<EntryPathData> incoming) {
// clearPreviousData();
// System.out.println("receive incoming data obj "+ incoming+ "for framework "+frameworkInformations.getFrameworkName());
// gatherData(incoming);
// System.out.println("data gathering complete. Found entries "+frameworkInformations.getListEntryPath().size());
// }
//
// private void clearPreviousData() {
// frameworkInformations.getListEntryPath().clear();
// }
//
//
// protected void gatherData(List<EntryPathData> incoming) {
// List<EntryPathData> listEntryPath = incoming;
// for (EntryPathData entry : listEntryPath) {
// if (entry.getMethodName() != null && !entry.getMethodName().contains("$")) {
// addEntryPath(entry);
// }
// }
// }
//
// @Override
// public FrameworkInformations getFrameworkInformations() {
// return frameworkInformations;
// }
//
// protected void addEntryPath(EntryPathData entryPath) {
// frameworkInformations.getListEntryPath().add(entryPath);
// }
//
// public String getInternalSignature(String className, String methodName) {
// String res = "";
// try {
// Class<?> c = Class.forName(className);
// for (Method m : c.getDeclaredMethods()) {
// if (m.getName().equals(methodName)) {
// res = Type.getMethodDescriptor(m);
// }
// }
//
// } catch (ClassNotFoundException e) {
// System.err.println("Can't construct classname " + className+" : "+ e);
// }
//
// return res;
// }
//
// public String getInternalSignature(Method m) {
// return Type.getMethodDescriptor(m);
// }
// }
// Path: h2hell-core/src/main/java/com/highway2urhell/service/impl/Struts1Service.java
import com.highway2urhell.VersionUtils;
import com.highway2urhell.service.AbstractLeechService;
package com.highway2urhell.service.impl;
public class Struts1Service extends AbstractLeechService {
public static final String FRAMEWORK_NAME = "STRUTS_1";
public Struts1Service() { | super(FRAMEWORK_NAME, VersionUtils.getVersion( |
highway-to-urhell/highway-to-urhell | h2hell-core/src/test/java/com/highway2urhell/collector/Struts1WithSpringCollectorTest.java | // Path: h2hell-core/src/main/java/com/highway2urhell/transformer/Struts1WithSpringTransformer.java
// public class Struts1WithSpringTransformer extends AbstractLeechTransformer {
//
// public Struts1WithSpringTransformer() {
// super("org/springframework/web/struts/ContextLoaderPlugIn");
// addImportPackage(collectPackages());
// }
//
// public static String[] collectPackages() {
// return new String[]{
// "com.highway2urhell",
// "com.highway2urhell.domain",
// "java.lang.reflect",
// "java.util",
// "org.apache.struts.action",
// "org.springframework.web.context"
// };
// }
//
// @Override
// protected void doTransform(CtClass cc) throws Exception {
// CtMethod m = cc.getMethod("init", "(Lorg/apache/struts/action/ActionServlet;Lorg/apache/struts/config/ModuleConfig;)V");
// m.insertAfter(collectBody());
//
// }
//
// public static String collectBody() {
// return "{\n" +
// " List listEntryPath = new ArrayList();\n" +
// " if (webApplicationContext != null && webApplicationContext.getBeanDefinitionNames() != null && webApplicationContext.getBeanDefinitionNames().length > 0) {\n" +
// " for (int i = 0; i < webApplicationContext.getBeanDefinitionNames().length; i++) {\n" +
// " String tmp = webApplicationContext.getBeanDefinitionNames()[i];\n" +
// " if (tmp.startsWith(\"/\")) {\n" +
// " Action toAdd = (Action) webApplicationContext.getBean(tmp, Action.class);\n" +
// " try {\n" +
// " Class c = Class.forName(toAdd.getClass().getName());\n" +
// " Method[] tabDeclared = c.getDeclaredMethods();\n" +
// " for (int m = 0; i < tabDeclared.length; i++) {\n" +
// " EntryPathData entry = new EntryPathData();\n" +
// " String resSignature = org.objectweb.asm.Type.getMethodDescriptor(tabDeclared[i]);\n" +
// " entry.setUri(tmp);\n" +
// " entry.setClassName(toAdd.getClass().getName());\n" +
// " entry.setMethodName(tabDeclared[m].getName());\n" +
// " entry.setSignatureName(resSignature);\n" +
// " List listEntryPathData = new ArrayList();\n" +
// " for (int j = 0; j < tabDeclared[m].getParameterTypes().length; j++) {\n" +
// " EntryPathParam param = new EntryPathParam();\n" +
// " param.setKey(\"\");\n" +
// " param.setTypeParam(TypeParam.PARAM_DATA);\n" +
// " param.setValue(tabDeclared[m].getParameterTypes()[j].getName());\n" +
// " listEntryPathData.add(param);\n" +
// " }\n" +
// " entry.setListEntryPathData(listEntryPathData);\n" +
// " System.err.println(entry.toString());\n" +
// " listEntryPath.add(entry);\n" +
// " }\n" +
// " } catch (ClassNotFoundException e) {\n" +
// " System.err.println(\"Error on invoke \" + toAdd.getClass().getName());\n" +
// " e.printStackTrace();\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " CoreEngine.getInstance().getFramework(\"STRUTS_SPRING_1\").receiveData(listEntryPath);\n" +
// "}";
// }
// }
//
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String extractBody(String in, String methodName) throws ParseException, FileNotFoundException {
// return extractMethod(JavaParser.parse(new FileInputStream(in)), methodName);
// }
//
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String[] extractPackages(String in) throws ParseException, FileNotFoundException {
// List<String> classes = extractImports(in);
// Set<String> ret = new TreeSet<String>();
// for (String aClass : classes) {
// ret.add(aClass.substring(0, aClass.lastIndexOf(".")));
// }
//
// return ret.toArray(new String[]{});
// }
| import com.github.javaparser.ParseException;
import com.highway2urhell.transformer.Struts1WithSpringTransformer;
import org.junit.Test;
import java.io.FileNotFoundException;
import static com.highway2urhell.utils.ParsingUtil.extractBody;
import static com.highway2urhell.utils.ParsingUtil.extractPackages;
import static org.fest.assertions.Assertions.assertThat; | package com.highway2urhell.collector;
public class Struts1WithSpringCollectorTest {
@Test
public void checkScript() throws FileNotFoundException, ParseException { | // Path: h2hell-core/src/main/java/com/highway2urhell/transformer/Struts1WithSpringTransformer.java
// public class Struts1WithSpringTransformer extends AbstractLeechTransformer {
//
// public Struts1WithSpringTransformer() {
// super("org/springframework/web/struts/ContextLoaderPlugIn");
// addImportPackage(collectPackages());
// }
//
// public static String[] collectPackages() {
// return new String[]{
// "com.highway2urhell",
// "com.highway2urhell.domain",
// "java.lang.reflect",
// "java.util",
// "org.apache.struts.action",
// "org.springframework.web.context"
// };
// }
//
// @Override
// protected void doTransform(CtClass cc) throws Exception {
// CtMethod m = cc.getMethod("init", "(Lorg/apache/struts/action/ActionServlet;Lorg/apache/struts/config/ModuleConfig;)V");
// m.insertAfter(collectBody());
//
// }
//
// public static String collectBody() {
// return "{\n" +
// " List listEntryPath = new ArrayList();\n" +
// " if (webApplicationContext != null && webApplicationContext.getBeanDefinitionNames() != null && webApplicationContext.getBeanDefinitionNames().length > 0) {\n" +
// " for (int i = 0; i < webApplicationContext.getBeanDefinitionNames().length; i++) {\n" +
// " String tmp = webApplicationContext.getBeanDefinitionNames()[i];\n" +
// " if (tmp.startsWith(\"/\")) {\n" +
// " Action toAdd = (Action) webApplicationContext.getBean(tmp, Action.class);\n" +
// " try {\n" +
// " Class c = Class.forName(toAdd.getClass().getName());\n" +
// " Method[] tabDeclared = c.getDeclaredMethods();\n" +
// " for (int m = 0; i < tabDeclared.length; i++) {\n" +
// " EntryPathData entry = new EntryPathData();\n" +
// " String resSignature = org.objectweb.asm.Type.getMethodDescriptor(tabDeclared[i]);\n" +
// " entry.setUri(tmp);\n" +
// " entry.setClassName(toAdd.getClass().getName());\n" +
// " entry.setMethodName(tabDeclared[m].getName());\n" +
// " entry.setSignatureName(resSignature);\n" +
// " List listEntryPathData = new ArrayList();\n" +
// " for (int j = 0; j < tabDeclared[m].getParameterTypes().length; j++) {\n" +
// " EntryPathParam param = new EntryPathParam();\n" +
// " param.setKey(\"\");\n" +
// " param.setTypeParam(TypeParam.PARAM_DATA);\n" +
// " param.setValue(tabDeclared[m].getParameterTypes()[j].getName());\n" +
// " listEntryPathData.add(param);\n" +
// " }\n" +
// " entry.setListEntryPathData(listEntryPathData);\n" +
// " System.err.println(entry.toString());\n" +
// " listEntryPath.add(entry);\n" +
// " }\n" +
// " } catch (ClassNotFoundException e) {\n" +
// " System.err.println(\"Error on invoke \" + toAdd.getClass().getName());\n" +
// " e.printStackTrace();\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " CoreEngine.getInstance().getFramework(\"STRUTS_SPRING_1\").receiveData(listEntryPath);\n" +
// "}";
// }
// }
//
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String extractBody(String in, String methodName) throws ParseException, FileNotFoundException {
// return extractMethod(JavaParser.parse(new FileInputStream(in)), methodName);
// }
//
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String[] extractPackages(String in) throws ParseException, FileNotFoundException {
// List<String> classes = extractImports(in);
// Set<String> ret = new TreeSet<String>();
// for (String aClass : classes) {
// ret.add(aClass.substring(0, aClass.lastIndexOf(".")));
// }
//
// return ret.toArray(new String[]{});
// }
// Path: h2hell-core/src/test/java/com/highway2urhell/collector/Struts1WithSpringCollectorTest.java
import com.github.javaparser.ParseException;
import com.highway2urhell.transformer.Struts1WithSpringTransformer;
import org.junit.Test;
import java.io.FileNotFoundException;
import static com.highway2urhell.utils.ParsingUtil.extractBody;
import static com.highway2urhell.utils.ParsingUtil.extractPackages;
import static org.fest.assertions.Assertions.assertThat;
package com.highway2urhell.collector;
public class Struts1WithSpringCollectorTest {
@Test
public void checkScript() throws FileNotFoundException, ParseException { | assertThat(Struts1WithSpringTransformer.collectBody()) |
highway-to-urhell/highway-to-urhell | h2hell-core/src/test/java/com/highway2urhell/collector/Struts1WithSpringCollectorTest.java | // Path: h2hell-core/src/main/java/com/highway2urhell/transformer/Struts1WithSpringTransformer.java
// public class Struts1WithSpringTransformer extends AbstractLeechTransformer {
//
// public Struts1WithSpringTransformer() {
// super("org/springframework/web/struts/ContextLoaderPlugIn");
// addImportPackage(collectPackages());
// }
//
// public static String[] collectPackages() {
// return new String[]{
// "com.highway2urhell",
// "com.highway2urhell.domain",
// "java.lang.reflect",
// "java.util",
// "org.apache.struts.action",
// "org.springframework.web.context"
// };
// }
//
// @Override
// protected void doTransform(CtClass cc) throws Exception {
// CtMethod m = cc.getMethod("init", "(Lorg/apache/struts/action/ActionServlet;Lorg/apache/struts/config/ModuleConfig;)V");
// m.insertAfter(collectBody());
//
// }
//
// public static String collectBody() {
// return "{\n" +
// " List listEntryPath = new ArrayList();\n" +
// " if (webApplicationContext != null && webApplicationContext.getBeanDefinitionNames() != null && webApplicationContext.getBeanDefinitionNames().length > 0) {\n" +
// " for (int i = 0; i < webApplicationContext.getBeanDefinitionNames().length; i++) {\n" +
// " String tmp = webApplicationContext.getBeanDefinitionNames()[i];\n" +
// " if (tmp.startsWith(\"/\")) {\n" +
// " Action toAdd = (Action) webApplicationContext.getBean(tmp, Action.class);\n" +
// " try {\n" +
// " Class c = Class.forName(toAdd.getClass().getName());\n" +
// " Method[] tabDeclared = c.getDeclaredMethods();\n" +
// " for (int m = 0; i < tabDeclared.length; i++) {\n" +
// " EntryPathData entry = new EntryPathData();\n" +
// " String resSignature = org.objectweb.asm.Type.getMethodDescriptor(tabDeclared[i]);\n" +
// " entry.setUri(tmp);\n" +
// " entry.setClassName(toAdd.getClass().getName());\n" +
// " entry.setMethodName(tabDeclared[m].getName());\n" +
// " entry.setSignatureName(resSignature);\n" +
// " List listEntryPathData = new ArrayList();\n" +
// " for (int j = 0; j < tabDeclared[m].getParameterTypes().length; j++) {\n" +
// " EntryPathParam param = new EntryPathParam();\n" +
// " param.setKey(\"\");\n" +
// " param.setTypeParam(TypeParam.PARAM_DATA);\n" +
// " param.setValue(tabDeclared[m].getParameterTypes()[j].getName());\n" +
// " listEntryPathData.add(param);\n" +
// " }\n" +
// " entry.setListEntryPathData(listEntryPathData);\n" +
// " System.err.println(entry.toString());\n" +
// " listEntryPath.add(entry);\n" +
// " }\n" +
// " } catch (ClassNotFoundException e) {\n" +
// " System.err.println(\"Error on invoke \" + toAdd.getClass().getName());\n" +
// " e.printStackTrace();\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " CoreEngine.getInstance().getFramework(\"STRUTS_SPRING_1\").receiveData(listEntryPath);\n" +
// "}";
// }
// }
//
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String extractBody(String in, String methodName) throws ParseException, FileNotFoundException {
// return extractMethod(JavaParser.parse(new FileInputStream(in)), methodName);
// }
//
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String[] extractPackages(String in) throws ParseException, FileNotFoundException {
// List<String> classes = extractImports(in);
// Set<String> ret = new TreeSet<String>();
// for (String aClass : classes) {
// ret.add(aClass.substring(0, aClass.lastIndexOf(".")));
// }
//
// return ret.toArray(new String[]{});
// }
| import com.github.javaparser.ParseException;
import com.highway2urhell.transformer.Struts1WithSpringTransformer;
import org.junit.Test;
import java.io.FileNotFoundException;
import static com.highway2urhell.utils.ParsingUtil.extractBody;
import static com.highway2urhell.utils.ParsingUtil.extractPackages;
import static org.fest.assertions.Assertions.assertThat; | package com.highway2urhell.collector;
public class Struts1WithSpringCollectorTest {
@Test
public void checkScript() throws FileNotFoundException, ParseException {
assertThat(Struts1WithSpringTransformer.collectBody()) | // Path: h2hell-core/src/main/java/com/highway2urhell/transformer/Struts1WithSpringTransformer.java
// public class Struts1WithSpringTransformer extends AbstractLeechTransformer {
//
// public Struts1WithSpringTransformer() {
// super("org/springframework/web/struts/ContextLoaderPlugIn");
// addImportPackage(collectPackages());
// }
//
// public static String[] collectPackages() {
// return new String[]{
// "com.highway2urhell",
// "com.highway2urhell.domain",
// "java.lang.reflect",
// "java.util",
// "org.apache.struts.action",
// "org.springframework.web.context"
// };
// }
//
// @Override
// protected void doTransform(CtClass cc) throws Exception {
// CtMethod m = cc.getMethod("init", "(Lorg/apache/struts/action/ActionServlet;Lorg/apache/struts/config/ModuleConfig;)V");
// m.insertAfter(collectBody());
//
// }
//
// public static String collectBody() {
// return "{\n" +
// " List listEntryPath = new ArrayList();\n" +
// " if (webApplicationContext != null && webApplicationContext.getBeanDefinitionNames() != null && webApplicationContext.getBeanDefinitionNames().length > 0) {\n" +
// " for (int i = 0; i < webApplicationContext.getBeanDefinitionNames().length; i++) {\n" +
// " String tmp = webApplicationContext.getBeanDefinitionNames()[i];\n" +
// " if (tmp.startsWith(\"/\")) {\n" +
// " Action toAdd = (Action) webApplicationContext.getBean(tmp, Action.class);\n" +
// " try {\n" +
// " Class c = Class.forName(toAdd.getClass().getName());\n" +
// " Method[] tabDeclared = c.getDeclaredMethods();\n" +
// " for (int m = 0; i < tabDeclared.length; i++) {\n" +
// " EntryPathData entry = new EntryPathData();\n" +
// " String resSignature = org.objectweb.asm.Type.getMethodDescriptor(tabDeclared[i]);\n" +
// " entry.setUri(tmp);\n" +
// " entry.setClassName(toAdd.getClass().getName());\n" +
// " entry.setMethodName(tabDeclared[m].getName());\n" +
// " entry.setSignatureName(resSignature);\n" +
// " List listEntryPathData = new ArrayList();\n" +
// " for (int j = 0; j < tabDeclared[m].getParameterTypes().length; j++) {\n" +
// " EntryPathParam param = new EntryPathParam();\n" +
// " param.setKey(\"\");\n" +
// " param.setTypeParam(TypeParam.PARAM_DATA);\n" +
// " param.setValue(tabDeclared[m].getParameterTypes()[j].getName());\n" +
// " listEntryPathData.add(param);\n" +
// " }\n" +
// " entry.setListEntryPathData(listEntryPathData);\n" +
// " System.err.println(entry.toString());\n" +
// " listEntryPath.add(entry);\n" +
// " }\n" +
// " } catch (ClassNotFoundException e) {\n" +
// " System.err.println(\"Error on invoke \" + toAdd.getClass().getName());\n" +
// " e.printStackTrace();\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " CoreEngine.getInstance().getFramework(\"STRUTS_SPRING_1\").receiveData(listEntryPath);\n" +
// "}";
// }
// }
//
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String extractBody(String in, String methodName) throws ParseException, FileNotFoundException {
// return extractMethod(JavaParser.parse(new FileInputStream(in)), methodName);
// }
//
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String[] extractPackages(String in) throws ParseException, FileNotFoundException {
// List<String> classes = extractImports(in);
// Set<String> ret = new TreeSet<String>();
// for (String aClass : classes) {
// ret.add(aClass.substring(0, aClass.lastIndexOf(".")));
// }
//
// return ret.toArray(new String[]{});
// }
// Path: h2hell-core/src/test/java/com/highway2urhell/collector/Struts1WithSpringCollectorTest.java
import com.github.javaparser.ParseException;
import com.highway2urhell.transformer.Struts1WithSpringTransformer;
import org.junit.Test;
import java.io.FileNotFoundException;
import static com.highway2urhell.utils.ParsingUtil.extractBody;
import static com.highway2urhell.utils.ParsingUtil.extractPackages;
import static org.fest.assertions.Assertions.assertThat;
package com.highway2urhell.collector;
public class Struts1WithSpringCollectorTest {
@Test
public void checkScript() throws FileNotFoundException, ParseException {
assertThat(Struts1WithSpringTransformer.collectBody()) | .isEqualTo(extractBody("./src/test/java/com/highway2urhell/collector/Struts1WithSpringCollector.java", "collectBody")); |
highway-to-urhell/highway-to-urhell | h2hell-core/src/test/java/com/highway2urhell/collector/Struts1WithSpringCollectorTest.java | // Path: h2hell-core/src/main/java/com/highway2urhell/transformer/Struts1WithSpringTransformer.java
// public class Struts1WithSpringTransformer extends AbstractLeechTransformer {
//
// public Struts1WithSpringTransformer() {
// super("org/springframework/web/struts/ContextLoaderPlugIn");
// addImportPackage(collectPackages());
// }
//
// public static String[] collectPackages() {
// return new String[]{
// "com.highway2urhell",
// "com.highway2urhell.domain",
// "java.lang.reflect",
// "java.util",
// "org.apache.struts.action",
// "org.springframework.web.context"
// };
// }
//
// @Override
// protected void doTransform(CtClass cc) throws Exception {
// CtMethod m = cc.getMethod("init", "(Lorg/apache/struts/action/ActionServlet;Lorg/apache/struts/config/ModuleConfig;)V");
// m.insertAfter(collectBody());
//
// }
//
// public static String collectBody() {
// return "{\n" +
// " List listEntryPath = new ArrayList();\n" +
// " if (webApplicationContext != null && webApplicationContext.getBeanDefinitionNames() != null && webApplicationContext.getBeanDefinitionNames().length > 0) {\n" +
// " for (int i = 0; i < webApplicationContext.getBeanDefinitionNames().length; i++) {\n" +
// " String tmp = webApplicationContext.getBeanDefinitionNames()[i];\n" +
// " if (tmp.startsWith(\"/\")) {\n" +
// " Action toAdd = (Action) webApplicationContext.getBean(tmp, Action.class);\n" +
// " try {\n" +
// " Class c = Class.forName(toAdd.getClass().getName());\n" +
// " Method[] tabDeclared = c.getDeclaredMethods();\n" +
// " for (int m = 0; i < tabDeclared.length; i++) {\n" +
// " EntryPathData entry = new EntryPathData();\n" +
// " String resSignature = org.objectweb.asm.Type.getMethodDescriptor(tabDeclared[i]);\n" +
// " entry.setUri(tmp);\n" +
// " entry.setClassName(toAdd.getClass().getName());\n" +
// " entry.setMethodName(tabDeclared[m].getName());\n" +
// " entry.setSignatureName(resSignature);\n" +
// " List listEntryPathData = new ArrayList();\n" +
// " for (int j = 0; j < tabDeclared[m].getParameterTypes().length; j++) {\n" +
// " EntryPathParam param = new EntryPathParam();\n" +
// " param.setKey(\"\");\n" +
// " param.setTypeParam(TypeParam.PARAM_DATA);\n" +
// " param.setValue(tabDeclared[m].getParameterTypes()[j].getName());\n" +
// " listEntryPathData.add(param);\n" +
// " }\n" +
// " entry.setListEntryPathData(listEntryPathData);\n" +
// " System.err.println(entry.toString());\n" +
// " listEntryPath.add(entry);\n" +
// " }\n" +
// " } catch (ClassNotFoundException e) {\n" +
// " System.err.println(\"Error on invoke \" + toAdd.getClass().getName());\n" +
// " e.printStackTrace();\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " CoreEngine.getInstance().getFramework(\"STRUTS_SPRING_1\").receiveData(listEntryPath);\n" +
// "}";
// }
// }
//
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String extractBody(String in, String methodName) throws ParseException, FileNotFoundException {
// return extractMethod(JavaParser.parse(new FileInputStream(in)), methodName);
// }
//
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String[] extractPackages(String in) throws ParseException, FileNotFoundException {
// List<String> classes = extractImports(in);
// Set<String> ret = new TreeSet<String>();
// for (String aClass : classes) {
// ret.add(aClass.substring(0, aClass.lastIndexOf(".")));
// }
//
// return ret.toArray(new String[]{});
// }
| import com.github.javaparser.ParseException;
import com.highway2urhell.transformer.Struts1WithSpringTransformer;
import org.junit.Test;
import java.io.FileNotFoundException;
import static com.highway2urhell.utils.ParsingUtil.extractBody;
import static com.highway2urhell.utils.ParsingUtil.extractPackages;
import static org.fest.assertions.Assertions.assertThat; | package com.highway2urhell.collector;
public class Struts1WithSpringCollectorTest {
@Test
public void checkScript() throws FileNotFoundException, ParseException {
assertThat(Struts1WithSpringTransformer.collectBody())
.isEqualTo(extractBody("./src/test/java/com/highway2urhell/collector/Struts1WithSpringCollector.java", "collectBody"));
assertThat(Struts1WithSpringTransformer.collectPackages()) | // Path: h2hell-core/src/main/java/com/highway2urhell/transformer/Struts1WithSpringTransformer.java
// public class Struts1WithSpringTransformer extends AbstractLeechTransformer {
//
// public Struts1WithSpringTransformer() {
// super("org/springframework/web/struts/ContextLoaderPlugIn");
// addImportPackage(collectPackages());
// }
//
// public static String[] collectPackages() {
// return new String[]{
// "com.highway2urhell",
// "com.highway2urhell.domain",
// "java.lang.reflect",
// "java.util",
// "org.apache.struts.action",
// "org.springframework.web.context"
// };
// }
//
// @Override
// protected void doTransform(CtClass cc) throws Exception {
// CtMethod m = cc.getMethod("init", "(Lorg/apache/struts/action/ActionServlet;Lorg/apache/struts/config/ModuleConfig;)V");
// m.insertAfter(collectBody());
//
// }
//
// public static String collectBody() {
// return "{\n" +
// " List listEntryPath = new ArrayList();\n" +
// " if (webApplicationContext != null && webApplicationContext.getBeanDefinitionNames() != null && webApplicationContext.getBeanDefinitionNames().length > 0) {\n" +
// " for (int i = 0; i < webApplicationContext.getBeanDefinitionNames().length; i++) {\n" +
// " String tmp = webApplicationContext.getBeanDefinitionNames()[i];\n" +
// " if (tmp.startsWith(\"/\")) {\n" +
// " Action toAdd = (Action) webApplicationContext.getBean(tmp, Action.class);\n" +
// " try {\n" +
// " Class c = Class.forName(toAdd.getClass().getName());\n" +
// " Method[] tabDeclared = c.getDeclaredMethods();\n" +
// " for (int m = 0; i < tabDeclared.length; i++) {\n" +
// " EntryPathData entry = new EntryPathData();\n" +
// " String resSignature = org.objectweb.asm.Type.getMethodDescriptor(tabDeclared[i]);\n" +
// " entry.setUri(tmp);\n" +
// " entry.setClassName(toAdd.getClass().getName());\n" +
// " entry.setMethodName(tabDeclared[m].getName());\n" +
// " entry.setSignatureName(resSignature);\n" +
// " List listEntryPathData = new ArrayList();\n" +
// " for (int j = 0; j < tabDeclared[m].getParameterTypes().length; j++) {\n" +
// " EntryPathParam param = new EntryPathParam();\n" +
// " param.setKey(\"\");\n" +
// " param.setTypeParam(TypeParam.PARAM_DATA);\n" +
// " param.setValue(tabDeclared[m].getParameterTypes()[j].getName());\n" +
// " listEntryPathData.add(param);\n" +
// " }\n" +
// " entry.setListEntryPathData(listEntryPathData);\n" +
// " System.err.println(entry.toString());\n" +
// " listEntryPath.add(entry);\n" +
// " }\n" +
// " } catch (ClassNotFoundException e) {\n" +
// " System.err.println(\"Error on invoke \" + toAdd.getClass().getName());\n" +
// " e.printStackTrace();\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " CoreEngine.getInstance().getFramework(\"STRUTS_SPRING_1\").receiveData(listEntryPath);\n" +
// "}";
// }
// }
//
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String extractBody(String in, String methodName) throws ParseException, FileNotFoundException {
// return extractMethod(JavaParser.parse(new FileInputStream(in)), methodName);
// }
//
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String[] extractPackages(String in) throws ParseException, FileNotFoundException {
// List<String> classes = extractImports(in);
// Set<String> ret = new TreeSet<String>();
// for (String aClass : classes) {
// ret.add(aClass.substring(0, aClass.lastIndexOf(".")));
// }
//
// return ret.toArray(new String[]{});
// }
// Path: h2hell-core/src/test/java/com/highway2urhell/collector/Struts1WithSpringCollectorTest.java
import com.github.javaparser.ParseException;
import com.highway2urhell.transformer.Struts1WithSpringTransformer;
import org.junit.Test;
import java.io.FileNotFoundException;
import static com.highway2urhell.utils.ParsingUtil.extractBody;
import static com.highway2urhell.utils.ParsingUtil.extractPackages;
import static org.fest.assertions.Assertions.assertThat;
package com.highway2urhell.collector;
public class Struts1WithSpringCollectorTest {
@Test
public void checkScript() throws FileNotFoundException, ParseException {
assertThat(Struts1WithSpringTransformer.collectBody())
.isEqualTo(extractBody("./src/test/java/com/highway2urhell/collector/Struts1WithSpringCollector.java", "collectBody"));
assertThat(Struts1WithSpringTransformer.collectPackages()) | .isEqualTo(extractPackages("./src/test/java/com/highway2urhell/collector/Struts1WithSpringCollector.java")); |
highway-to-urhell/highway-to-urhell | h2hell-core/src/main/java/com/highway2urhell/service/impl/StrutsSpring1Service.java | // Path: h2hell-core/src/main/java/com/highway2urhell/VersionUtils.java
// public class VersionUtils {
//
// public static final String UNKNOWN_VERSION = "UNKNOWN";
// public static final String NO_FRAMEWORK = "NO_FRAMEWORK";
//
// private VersionUtils() {
// }
//
// public static String getVersion(String clazzName, String groupId, String artifactId) {
// //check
// Class<?> clazz;
// try {
// clazz = Class.forName(clazzName);
// } catch (ClassNotFoundException e1) {
// return NO_FRAMEWORK;
// }
// String version = null;
//
// // try to load from maven properties first
// Properties p = new Properties();
// InputStream is = null;
//
// try {
// is = clazz.getResourceAsStream("/META-INF/maven/" + groupId + "/" + artifactId + "/pom.properties");
// if (is != null) {
// p.load(is);
// version = p.getProperty("version", "");
// }
// } catch (Exception e) {
// // ignore
// } finally {
// if (is != null) {
// try {
// is.close();
// } catch (IOException e) {
// // ignore
// }
// }
// }
//
// // try to load from manifest
// try {
// URL clazzRes = clazz.getResource('/' + clazz.getName().replace('.', '/') + ".class");
// String classResPath = clazzRes.getPath();
// Manifest manifest = null;
// if (classResPath.contains("!")) {
// classResPath = classResPath.split("!")[0];
// URL url = new URL("jar:" + classResPath + "!/");
// JarURLConnection jarConnection = (JarURLConnection) url.openConnection();
// manifest = jarConnection.getManifest();
// } else {
// is = clazz.getResourceAsStream(classResPath + "!/META-INF/MANIFEST.MF");
// if (is != null)
// manifest = new Manifest(is);
//
// }
// if (manifest != null) {
// Attributes attr = manifest.getMainAttributes();
// version = attr.getValue("Implementation-Version");
// }
// } catch (Exception e) {
// // ignore
// } finally {
// if (is != null) {
// try {
// is.close();
// } catch (IOException e) {
// // ignore
// }
// }
// }
//
//
// // fallback to using Java API
// if (version == null) {
// Package aPackage = clazz.getPackage();
// if (aPackage != null) {
// version = aPackage.getImplementationVersion();
// if (version == null) {
// version = aPackage.getSpecificationVersion();
// }
// }
// }
// if (version == null) {
// // we could not compute the version so use a blank
// version = UNKNOWN_VERSION;
// }
//
// return version;
// }
//
// }
//
// Path: h2hell-core/src/main/java/com/highway2urhell/service/AbstractLeechService.java
// public abstract class AbstractLeechService implements LeechService {
//
// private FrameworkInformations frameworkInformations = new FrameworkInformations();
// private boolean triggeredAtStartup = false;
//
// public AbstractLeechService(String frameworkName) {
// frameworkInformations.setFrameworkName(frameworkName);
// }
//
// public AbstractLeechService(String frameworkName, String version) {
// this(frameworkName);
// frameworkInformations.setVersion(version);
// }
//
// @Override
// public boolean isTriggeredAtStartup() {
// return triggeredAtStartup;
// }
//
// protected void setTriggerAtStartup(boolean triggeredAtStartup) {
// this.triggeredAtStartup = triggeredAtStartup;
// }
//
// public void receiveData(List<EntryPathData> incoming) {
// clearPreviousData();
// System.out.println("receive incoming data obj "+ incoming+ "for framework "+frameworkInformations.getFrameworkName());
// gatherData(incoming);
// System.out.println("data gathering complete. Found entries "+frameworkInformations.getListEntryPath().size());
// }
//
// private void clearPreviousData() {
// frameworkInformations.getListEntryPath().clear();
// }
//
//
// protected void gatherData(List<EntryPathData> incoming) {
// List<EntryPathData> listEntryPath = incoming;
// for (EntryPathData entry : listEntryPath) {
// if (entry.getMethodName() != null && !entry.getMethodName().contains("$")) {
// addEntryPath(entry);
// }
// }
// }
//
// @Override
// public FrameworkInformations getFrameworkInformations() {
// return frameworkInformations;
// }
//
// protected void addEntryPath(EntryPathData entryPath) {
// frameworkInformations.getListEntryPath().add(entryPath);
// }
//
// public String getInternalSignature(String className, String methodName) {
// String res = "";
// try {
// Class<?> c = Class.forName(className);
// for (Method m : c.getDeclaredMethods()) {
// if (m.getName().equals(methodName)) {
// res = Type.getMethodDescriptor(m);
// }
// }
//
// } catch (ClassNotFoundException e) {
// System.err.println("Can't construct classname " + className+" : "+ e);
// }
//
// return res;
// }
//
// public String getInternalSignature(Method m) {
// return Type.getMethodDescriptor(m);
// }
// }
| import com.highway2urhell.VersionUtils;
import com.highway2urhell.service.AbstractLeechService; | package com.highway2urhell.service.impl;
public class StrutsSpring1Service extends AbstractLeechService {
public static final String FRAMEWORK_NAME = "STRUTS_SPRING_1";
public StrutsSpring1Service() { | // Path: h2hell-core/src/main/java/com/highway2urhell/VersionUtils.java
// public class VersionUtils {
//
// public static final String UNKNOWN_VERSION = "UNKNOWN";
// public static final String NO_FRAMEWORK = "NO_FRAMEWORK";
//
// private VersionUtils() {
// }
//
// public static String getVersion(String clazzName, String groupId, String artifactId) {
// //check
// Class<?> clazz;
// try {
// clazz = Class.forName(clazzName);
// } catch (ClassNotFoundException e1) {
// return NO_FRAMEWORK;
// }
// String version = null;
//
// // try to load from maven properties first
// Properties p = new Properties();
// InputStream is = null;
//
// try {
// is = clazz.getResourceAsStream("/META-INF/maven/" + groupId + "/" + artifactId + "/pom.properties");
// if (is != null) {
// p.load(is);
// version = p.getProperty("version", "");
// }
// } catch (Exception e) {
// // ignore
// } finally {
// if (is != null) {
// try {
// is.close();
// } catch (IOException e) {
// // ignore
// }
// }
// }
//
// // try to load from manifest
// try {
// URL clazzRes = clazz.getResource('/' + clazz.getName().replace('.', '/') + ".class");
// String classResPath = clazzRes.getPath();
// Manifest manifest = null;
// if (classResPath.contains("!")) {
// classResPath = classResPath.split("!")[0];
// URL url = new URL("jar:" + classResPath + "!/");
// JarURLConnection jarConnection = (JarURLConnection) url.openConnection();
// manifest = jarConnection.getManifest();
// } else {
// is = clazz.getResourceAsStream(classResPath + "!/META-INF/MANIFEST.MF");
// if (is != null)
// manifest = new Manifest(is);
//
// }
// if (manifest != null) {
// Attributes attr = manifest.getMainAttributes();
// version = attr.getValue("Implementation-Version");
// }
// } catch (Exception e) {
// // ignore
// } finally {
// if (is != null) {
// try {
// is.close();
// } catch (IOException e) {
// // ignore
// }
// }
// }
//
//
// // fallback to using Java API
// if (version == null) {
// Package aPackage = clazz.getPackage();
// if (aPackage != null) {
// version = aPackage.getImplementationVersion();
// if (version == null) {
// version = aPackage.getSpecificationVersion();
// }
// }
// }
// if (version == null) {
// // we could not compute the version so use a blank
// version = UNKNOWN_VERSION;
// }
//
// return version;
// }
//
// }
//
// Path: h2hell-core/src/main/java/com/highway2urhell/service/AbstractLeechService.java
// public abstract class AbstractLeechService implements LeechService {
//
// private FrameworkInformations frameworkInformations = new FrameworkInformations();
// private boolean triggeredAtStartup = false;
//
// public AbstractLeechService(String frameworkName) {
// frameworkInformations.setFrameworkName(frameworkName);
// }
//
// public AbstractLeechService(String frameworkName, String version) {
// this(frameworkName);
// frameworkInformations.setVersion(version);
// }
//
// @Override
// public boolean isTriggeredAtStartup() {
// return triggeredAtStartup;
// }
//
// protected void setTriggerAtStartup(boolean triggeredAtStartup) {
// this.triggeredAtStartup = triggeredAtStartup;
// }
//
// public void receiveData(List<EntryPathData> incoming) {
// clearPreviousData();
// System.out.println("receive incoming data obj "+ incoming+ "for framework "+frameworkInformations.getFrameworkName());
// gatherData(incoming);
// System.out.println("data gathering complete. Found entries "+frameworkInformations.getListEntryPath().size());
// }
//
// private void clearPreviousData() {
// frameworkInformations.getListEntryPath().clear();
// }
//
//
// protected void gatherData(List<EntryPathData> incoming) {
// List<EntryPathData> listEntryPath = incoming;
// for (EntryPathData entry : listEntryPath) {
// if (entry.getMethodName() != null && !entry.getMethodName().contains("$")) {
// addEntryPath(entry);
// }
// }
// }
//
// @Override
// public FrameworkInformations getFrameworkInformations() {
// return frameworkInformations;
// }
//
// protected void addEntryPath(EntryPathData entryPath) {
// frameworkInformations.getListEntryPath().add(entryPath);
// }
//
// public String getInternalSignature(String className, String methodName) {
// String res = "";
// try {
// Class<?> c = Class.forName(className);
// for (Method m : c.getDeclaredMethods()) {
// if (m.getName().equals(methodName)) {
// res = Type.getMethodDescriptor(m);
// }
// }
//
// } catch (ClassNotFoundException e) {
// System.err.println("Can't construct classname " + className+" : "+ e);
// }
//
// return res;
// }
//
// public String getInternalSignature(Method m) {
// return Type.getMethodDescriptor(m);
// }
// }
// Path: h2hell-core/src/main/java/com/highway2urhell/service/impl/StrutsSpring1Service.java
import com.highway2urhell.VersionUtils;
import com.highway2urhell.service.AbstractLeechService;
package com.highway2urhell.service.impl;
public class StrutsSpring1Service extends AbstractLeechService {
public static final String FRAMEWORK_NAME = "STRUTS_SPRING_1";
public StrutsSpring1Service() { | super(FRAMEWORK_NAME, VersionUtils.getVersion( |
highway-to-urhell/highway-to-urhell | h2hell-core/src/main/java/com/highway2urhell/service/impl/GwtService.java | // Path: h2hell-core/src/main/java/com/highway2urhell/VersionUtils.java
// public class VersionUtils {
//
// public static final String UNKNOWN_VERSION = "UNKNOWN";
// public static final String NO_FRAMEWORK = "NO_FRAMEWORK";
//
// private VersionUtils() {
// }
//
// public static String getVersion(String clazzName, String groupId, String artifactId) {
// //check
// Class<?> clazz;
// try {
// clazz = Class.forName(clazzName);
// } catch (ClassNotFoundException e1) {
// return NO_FRAMEWORK;
// }
// String version = null;
//
// // try to load from maven properties first
// Properties p = new Properties();
// InputStream is = null;
//
// try {
// is = clazz.getResourceAsStream("/META-INF/maven/" + groupId + "/" + artifactId + "/pom.properties");
// if (is != null) {
// p.load(is);
// version = p.getProperty("version", "");
// }
// } catch (Exception e) {
// // ignore
// } finally {
// if (is != null) {
// try {
// is.close();
// } catch (IOException e) {
// // ignore
// }
// }
// }
//
// // try to load from manifest
// try {
// URL clazzRes = clazz.getResource('/' + clazz.getName().replace('.', '/') + ".class");
// String classResPath = clazzRes.getPath();
// Manifest manifest = null;
// if (classResPath.contains("!")) {
// classResPath = classResPath.split("!")[0];
// URL url = new URL("jar:" + classResPath + "!/");
// JarURLConnection jarConnection = (JarURLConnection) url.openConnection();
// manifest = jarConnection.getManifest();
// } else {
// is = clazz.getResourceAsStream(classResPath + "!/META-INF/MANIFEST.MF");
// if (is != null)
// manifest = new Manifest(is);
//
// }
// if (manifest != null) {
// Attributes attr = manifest.getMainAttributes();
// version = attr.getValue("Implementation-Version");
// }
// } catch (Exception e) {
// // ignore
// } finally {
// if (is != null) {
// try {
// is.close();
// } catch (IOException e) {
// // ignore
// }
// }
// }
//
//
// // fallback to using Java API
// if (version == null) {
// Package aPackage = clazz.getPackage();
// if (aPackage != null) {
// version = aPackage.getImplementationVersion();
// if (version == null) {
// version = aPackage.getSpecificationVersion();
// }
// }
// }
// if (version == null) {
// // we could not compute the version so use a blank
// version = UNKNOWN_VERSION;
// }
//
// return version;
// }
//
// }
//
// Path: h2hell-core/src/main/java/com/highway2urhell/service/AbstractLeechService.java
// public abstract class AbstractLeechService implements LeechService {
//
// private FrameworkInformations frameworkInformations = new FrameworkInformations();
// private boolean triggeredAtStartup = false;
//
// public AbstractLeechService(String frameworkName) {
// frameworkInformations.setFrameworkName(frameworkName);
// }
//
// public AbstractLeechService(String frameworkName, String version) {
// this(frameworkName);
// frameworkInformations.setVersion(version);
// }
//
// @Override
// public boolean isTriggeredAtStartup() {
// return triggeredAtStartup;
// }
//
// protected void setTriggerAtStartup(boolean triggeredAtStartup) {
// this.triggeredAtStartup = triggeredAtStartup;
// }
//
// public void receiveData(List<EntryPathData> incoming) {
// clearPreviousData();
// System.out.println("receive incoming data obj "+ incoming+ "for framework "+frameworkInformations.getFrameworkName());
// gatherData(incoming);
// System.out.println("data gathering complete. Found entries "+frameworkInformations.getListEntryPath().size());
// }
//
// private void clearPreviousData() {
// frameworkInformations.getListEntryPath().clear();
// }
//
//
// protected void gatherData(List<EntryPathData> incoming) {
// List<EntryPathData> listEntryPath = incoming;
// for (EntryPathData entry : listEntryPath) {
// if (entry.getMethodName() != null && !entry.getMethodName().contains("$")) {
// addEntryPath(entry);
// }
// }
// }
//
// @Override
// public FrameworkInformations getFrameworkInformations() {
// return frameworkInformations;
// }
//
// protected void addEntryPath(EntryPathData entryPath) {
// frameworkInformations.getListEntryPath().add(entryPath);
// }
//
// public String getInternalSignature(String className, String methodName) {
// String res = "";
// try {
// Class<?> c = Class.forName(className);
// for (Method m : c.getDeclaredMethods()) {
// if (m.getName().equals(methodName)) {
// res = Type.getMethodDescriptor(m);
// }
// }
//
// } catch (ClassNotFoundException e) {
// System.err.println("Can't construct classname " + className+" : "+ e);
// }
//
// return res;
// }
//
// public String getInternalSignature(Method m) {
// return Type.getMethodDescriptor(m);
// }
// }
| import com.highway2urhell.VersionUtils;
import com.highway2urhell.service.AbstractLeechService; | package com.highway2urhell.service.impl;
public class GwtService extends AbstractLeechService {
public static final String FRAMEWORK_NAME = "GWT";
public GwtService() { | // Path: h2hell-core/src/main/java/com/highway2urhell/VersionUtils.java
// public class VersionUtils {
//
// public static final String UNKNOWN_VERSION = "UNKNOWN";
// public static final String NO_FRAMEWORK = "NO_FRAMEWORK";
//
// private VersionUtils() {
// }
//
// public static String getVersion(String clazzName, String groupId, String artifactId) {
// //check
// Class<?> clazz;
// try {
// clazz = Class.forName(clazzName);
// } catch (ClassNotFoundException e1) {
// return NO_FRAMEWORK;
// }
// String version = null;
//
// // try to load from maven properties first
// Properties p = new Properties();
// InputStream is = null;
//
// try {
// is = clazz.getResourceAsStream("/META-INF/maven/" + groupId + "/" + artifactId + "/pom.properties");
// if (is != null) {
// p.load(is);
// version = p.getProperty("version", "");
// }
// } catch (Exception e) {
// // ignore
// } finally {
// if (is != null) {
// try {
// is.close();
// } catch (IOException e) {
// // ignore
// }
// }
// }
//
// // try to load from manifest
// try {
// URL clazzRes = clazz.getResource('/' + clazz.getName().replace('.', '/') + ".class");
// String classResPath = clazzRes.getPath();
// Manifest manifest = null;
// if (classResPath.contains("!")) {
// classResPath = classResPath.split("!")[0];
// URL url = new URL("jar:" + classResPath + "!/");
// JarURLConnection jarConnection = (JarURLConnection) url.openConnection();
// manifest = jarConnection.getManifest();
// } else {
// is = clazz.getResourceAsStream(classResPath + "!/META-INF/MANIFEST.MF");
// if (is != null)
// manifest = new Manifest(is);
//
// }
// if (manifest != null) {
// Attributes attr = manifest.getMainAttributes();
// version = attr.getValue("Implementation-Version");
// }
// } catch (Exception e) {
// // ignore
// } finally {
// if (is != null) {
// try {
// is.close();
// } catch (IOException e) {
// // ignore
// }
// }
// }
//
//
// // fallback to using Java API
// if (version == null) {
// Package aPackage = clazz.getPackage();
// if (aPackage != null) {
// version = aPackage.getImplementationVersion();
// if (version == null) {
// version = aPackage.getSpecificationVersion();
// }
// }
// }
// if (version == null) {
// // we could not compute the version so use a blank
// version = UNKNOWN_VERSION;
// }
//
// return version;
// }
//
// }
//
// Path: h2hell-core/src/main/java/com/highway2urhell/service/AbstractLeechService.java
// public abstract class AbstractLeechService implements LeechService {
//
// private FrameworkInformations frameworkInformations = new FrameworkInformations();
// private boolean triggeredAtStartup = false;
//
// public AbstractLeechService(String frameworkName) {
// frameworkInformations.setFrameworkName(frameworkName);
// }
//
// public AbstractLeechService(String frameworkName, String version) {
// this(frameworkName);
// frameworkInformations.setVersion(version);
// }
//
// @Override
// public boolean isTriggeredAtStartup() {
// return triggeredAtStartup;
// }
//
// protected void setTriggerAtStartup(boolean triggeredAtStartup) {
// this.triggeredAtStartup = triggeredAtStartup;
// }
//
// public void receiveData(List<EntryPathData> incoming) {
// clearPreviousData();
// System.out.println("receive incoming data obj "+ incoming+ "for framework "+frameworkInformations.getFrameworkName());
// gatherData(incoming);
// System.out.println("data gathering complete. Found entries "+frameworkInformations.getListEntryPath().size());
// }
//
// private void clearPreviousData() {
// frameworkInformations.getListEntryPath().clear();
// }
//
//
// protected void gatherData(List<EntryPathData> incoming) {
// List<EntryPathData> listEntryPath = incoming;
// for (EntryPathData entry : listEntryPath) {
// if (entry.getMethodName() != null && !entry.getMethodName().contains("$")) {
// addEntryPath(entry);
// }
// }
// }
//
// @Override
// public FrameworkInformations getFrameworkInformations() {
// return frameworkInformations;
// }
//
// protected void addEntryPath(EntryPathData entryPath) {
// frameworkInformations.getListEntryPath().add(entryPath);
// }
//
// public String getInternalSignature(String className, String methodName) {
// String res = "";
// try {
// Class<?> c = Class.forName(className);
// for (Method m : c.getDeclaredMethods()) {
// if (m.getName().equals(methodName)) {
// res = Type.getMethodDescriptor(m);
// }
// }
//
// } catch (ClassNotFoundException e) {
// System.err.println("Can't construct classname " + className+" : "+ e);
// }
//
// return res;
// }
//
// public String getInternalSignature(Method m) {
// return Type.getMethodDescriptor(m);
// }
// }
// Path: h2hell-core/src/main/java/com/highway2urhell/service/impl/GwtService.java
import com.highway2urhell.VersionUtils;
import com.highway2urhell.service.AbstractLeechService;
package com.highway2urhell.service.impl;
public class GwtService extends AbstractLeechService {
public static final String FRAMEWORK_NAME = "GWT";
public GwtService() { | super(FRAMEWORK_NAME, VersionUtils.getVersion( |
highway-to-urhell/highway-to-urhell | h2hell-core/src/test/java/com/highway2urhell/collector/Struts2CollectorTest.java | // Path: h2hell-core/src/main/java/com/highway2urhell/transformer/Struts2Transformer.java
// public class Struts2Transformer extends AbstractLeechTransformer {
//
// public Struts2Transformer() {
// super("org/apache/struts2/dispatcher/ng/filter/StrutsPrepareAndExecuteFilter");
// addImportPackage(collectPackages());
// }
//
// public static String[] collectPackages() {
// return new String[]{
// "com.highway2urhell",
// "com.highway2urhell.domain",
// "com.opensymphony.xwork2.config",
// "com.opensymphony.xwork2.config.entities",
// "java.lang.reflect",
// "java.util",
// "org.apache.struts2.dispatcher"
// };
// }
//
// @Override
// protected void doTransform(CtClass cc) throws Exception {
// CtMethod m = cc
// .getMethod("postInit",
// "(Lorg/apache/struts2/dispatcher/Dispatcher;Ljavax/servlet/FilterConfig;)V");
// m.insertBefore(collectBody());
// }
//
// public static String collectBody() {
// return "{\n" +
// " List listEntryPath = new ArrayList();\n" +
// " ConfigurationManager cm = dispatcher.getConfigurationManager();\n" +
// " Configuration cf = cm.getConfiguration();\n" +
// " Collection colPackages = cf.getPackageConfigs().values();\n" +
// " if (colPackages != null) {\n" +
// " Iterator ite = colPackages.iterator();\n" +
// " while (ite.hasNext()) {\n" +
// " PackageConfig pack = (PackageConfig) ite.next();\n" +
// " Collection colActionConfigs = pack.getActionConfigs().values();\n" +
// " Iterator iteCol = colActionConfigs.iterator();\n" +
// " while (iteCol.hasNext()) {\n" +
// " ActionConfig action = (ActionConfig) iteCol.next();\n" +
// " if (action.getClassName() != null && !\"\".equals(action.getClassName())) {\n" +
// " try {\n" +
// " Class c = Class.forName(action.getClassName());\n" +
// " Method[] tabM = c.getDeclaredMethods();\n" +
// " for (int i = 0; i < tabM.length; i++) {\n" +
// " String scope = Modifier.toString(tabM[i].getModifiers());\n" +
// " if (scope.startsWith(\"public\") && !\"wait\".equals(tabM[i].getName()) && !\"notifyall\".equals(tabM[i].getName().toLowerCase()) && !\"notify\".equals(tabM[i].getName().toLowerCase()) && !\"getclass\".equals(tabM[i].getName().toLowerCase()) && !\"equals\".equals(tabM[i].getName().toLowerCase()) && !\"tostring\".equals(tabM[i].getName().toLowerCase()) && !\"wait\".equals(tabM[i].getName().toLowerCase()) && !\"hashcode\".equals(tabM[i].getName().toLowerCase())) {\n" +
// " Method m = tabM[i];\n" +
// " EntryPathData entry = new EntryPathData();\n" +
// " entry.setTypePath(TypePath.DYNAMIC);\n" +
// " entry.setClassName(action.getClassName());\n" +
// " entry.setMethodName(m.getName());\n" +
// " entry.setUri(action.getName());\n" +
// " entry.setSignatureName(org.objectweb.asm.Type.getMethodDescriptor(m));\n" +
// " List listEntryPathData = new ArrayList();\n" +
// " for (int j = 0; j < m.getParameterTypes().length; j++) {\n" +
// " EntryPathParam param = new EntryPathParam();\n" +
// " param.setKey(\"\");\n" +
// " param.setTypeParam(TypeParam.PARAM_DATA);\n" +
// " param.setValue(m.getParameterTypes()[j].getName());\n" +
// " listEntryPathData.add(param);\n" +
// " }\n" +
// " entry.setListEntryPathData(listEntryPathData);\n" +
// " listEntryPath.add(entry);\n" +
// " }\n" +
// " }\n" +
// " } catch (ClassNotFoundException e) {\n" +
// " e.printStackTrace();\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " CoreEngine.getInstance().getFramework(\"STRUTS_2\").receiveData(listEntryPath);\n" +
// "}";
// }
// }
//
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String extractBody(String in, String methodName) throws ParseException, FileNotFoundException {
// return extractMethod(JavaParser.parse(new FileInputStream(in)), methodName);
// }
//
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String[] extractPackages(String in) throws ParseException, FileNotFoundException {
// List<String> classes = extractImports(in);
// Set<String> ret = new TreeSet<String>();
// for (String aClass : classes) {
// ret.add(aClass.substring(0, aClass.lastIndexOf(".")));
// }
//
// return ret.toArray(new String[]{});
// }
| import com.github.javaparser.ParseException;
import com.highway2urhell.transformer.Struts2Transformer;
import org.junit.Test;
import java.io.FileNotFoundException;
import static com.highway2urhell.utils.ParsingUtil.extractBody;
import static com.highway2urhell.utils.ParsingUtil.extractPackages;
import static org.fest.assertions.Assertions.assertThat; | package com.highway2urhell.collector;
public class Struts2CollectorTest {
@Test
public void checkScript() throws FileNotFoundException, ParseException { | // Path: h2hell-core/src/main/java/com/highway2urhell/transformer/Struts2Transformer.java
// public class Struts2Transformer extends AbstractLeechTransformer {
//
// public Struts2Transformer() {
// super("org/apache/struts2/dispatcher/ng/filter/StrutsPrepareAndExecuteFilter");
// addImportPackage(collectPackages());
// }
//
// public static String[] collectPackages() {
// return new String[]{
// "com.highway2urhell",
// "com.highway2urhell.domain",
// "com.opensymphony.xwork2.config",
// "com.opensymphony.xwork2.config.entities",
// "java.lang.reflect",
// "java.util",
// "org.apache.struts2.dispatcher"
// };
// }
//
// @Override
// protected void doTransform(CtClass cc) throws Exception {
// CtMethod m = cc
// .getMethod("postInit",
// "(Lorg/apache/struts2/dispatcher/Dispatcher;Ljavax/servlet/FilterConfig;)V");
// m.insertBefore(collectBody());
// }
//
// public static String collectBody() {
// return "{\n" +
// " List listEntryPath = new ArrayList();\n" +
// " ConfigurationManager cm = dispatcher.getConfigurationManager();\n" +
// " Configuration cf = cm.getConfiguration();\n" +
// " Collection colPackages = cf.getPackageConfigs().values();\n" +
// " if (colPackages != null) {\n" +
// " Iterator ite = colPackages.iterator();\n" +
// " while (ite.hasNext()) {\n" +
// " PackageConfig pack = (PackageConfig) ite.next();\n" +
// " Collection colActionConfigs = pack.getActionConfigs().values();\n" +
// " Iterator iteCol = colActionConfigs.iterator();\n" +
// " while (iteCol.hasNext()) {\n" +
// " ActionConfig action = (ActionConfig) iteCol.next();\n" +
// " if (action.getClassName() != null && !\"\".equals(action.getClassName())) {\n" +
// " try {\n" +
// " Class c = Class.forName(action.getClassName());\n" +
// " Method[] tabM = c.getDeclaredMethods();\n" +
// " for (int i = 0; i < tabM.length; i++) {\n" +
// " String scope = Modifier.toString(tabM[i].getModifiers());\n" +
// " if (scope.startsWith(\"public\") && !\"wait\".equals(tabM[i].getName()) && !\"notifyall\".equals(tabM[i].getName().toLowerCase()) && !\"notify\".equals(tabM[i].getName().toLowerCase()) && !\"getclass\".equals(tabM[i].getName().toLowerCase()) && !\"equals\".equals(tabM[i].getName().toLowerCase()) && !\"tostring\".equals(tabM[i].getName().toLowerCase()) && !\"wait\".equals(tabM[i].getName().toLowerCase()) && !\"hashcode\".equals(tabM[i].getName().toLowerCase())) {\n" +
// " Method m = tabM[i];\n" +
// " EntryPathData entry = new EntryPathData();\n" +
// " entry.setTypePath(TypePath.DYNAMIC);\n" +
// " entry.setClassName(action.getClassName());\n" +
// " entry.setMethodName(m.getName());\n" +
// " entry.setUri(action.getName());\n" +
// " entry.setSignatureName(org.objectweb.asm.Type.getMethodDescriptor(m));\n" +
// " List listEntryPathData = new ArrayList();\n" +
// " for (int j = 0; j < m.getParameterTypes().length; j++) {\n" +
// " EntryPathParam param = new EntryPathParam();\n" +
// " param.setKey(\"\");\n" +
// " param.setTypeParam(TypeParam.PARAM_DATA);\n" +
// " param.setValue(m.getParameterTypes()[j].getName());\n" +
// " listEntryPathData.add(param);\n" +
// " }\n" +
// " entry.setListEntryPathData(listEntryPathData);\n" +
// " listEntryPath.add(entry);\n" +
// " }\n" +
// " }\n" +
// " } catch (ClassNotFoundException e) {\n" +
// " e.printStackTrace();\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " CoreEngine.getInstance().getFramework(\"STRUTS_2\").receiveData(listEntryPath);\n" +
// "}";
// }
// }
//
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String extractBody(String in, String methodName) throws ParseException, FileNotFoundException {
// return extractMethod(JavaParser.parse(new FileInputStream(in)), methodName);
// }
//
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String[] extractPackages(String in) throws ParseException, FileNotFoundException {
// List<String> classes = extractImports(in);
// Set<String> ret = new TreeSet<String>();
// for (String aClass : classes) {
// ret.add(aClass.substring(0, aClass.lastIndexOf(".")));
// }
//
// return ret.toArray(new String[]{});
// }
// Path: h2hell-core/src/test/java/com/highway2urhell/collector/Struts2CollectorTest.java
import com.github.javaparser.ParseException;
import com.highway2urhell.transformer.Struts2Transformer;
import org.junit.Test;
import java.io.FileNotFoundException;
import static com.highway2urhell.utils.ParsingUtil.extractBody;
import static com.highway2urhell.utils.ParsingUtil.extractPackages;
import static org.fest.assertions.Assertions.assertThat;
package com.highway2urhell.collector;
public class Struts2CollectorTest {
@Test
public void checkScript() throws FileNotFoundException, ParseException { | assertThat(Struts2Transformer.collectBody()) |
highway-to-urhell/highway-to-urhell | h2hell-core/src/test/java/com/highway2urhell/collector/Struts2CollectorTest.java | // Path: h2hell-core/src/main/java/com/highway2urhell/transformer/Struts2Transformer.java
// public class Struts2Transformer extends AbstractLeechTransformer {
//
// public Struts2Transformer() {
// super("org/apache/struts2/dispatcher/ng/filter/StrutsPrepareAndExecuteFilter");
// addImportPackage(collectPackages());
// }
//
// public static String[] collectPackages() {
// return new String[]{
// "com.highway2urhell",
// "com.highway2urhell.domain",
// "com.opensymphony.xwork2.config",
// "com.opensymphony.xwork2.config.entities",
// "java.lang.reflect",
// "java.util",
// "org.apache.struts2.dispatcher"
// };
// }
//
// @Override
// protected void doTransform(CtClass cc) throws Exception {
// CtMethod m = cc
// .getMethod("postInit",
// "(Lorg/apache/struts2/dispatcher/Dispatcher;Ljavax/servlet/FilterConfig;)V");
// m.insertBefore(collectBody());
// }
//
// public static String collectBody() {
// return "{\n" +
// " List listEntryPath = new ArrayList();\n" +
// " ConfigurationManager cm = dispatcher.getConfigurationManager();\n" +
// " Configuration cf = cm.getConfiguration();\n" +
// " Collection colPackages = cf.getPackageConfigs().values();\n" +
// " if (colPackages != null) {\n" +
// " Iterator ite = colPackages.iterator();\n" +
// " while (ite.hasNext()) {\n" +
// " PackageConfig pack = (PackageConfig) ite.next();\n" +
// " Collection colActionConfigs = pack.getActionConfigs().values();\n" +
// " Iterator iteCol = colActionConfigs.iterator();\n" +
// " while (iteCol.hasNext()) {\n" +
// " ActionConfig action = (ActionConfig) iteCol.next();\n" +
// " if (action.getClassName() != null && !\"\".equals(action.getClassName())) {\n" +
// " try {\n" +
// " Class c = Class.forName(action.getClassName());\n" +
// " Method[] tabM = c.getDeclaredMethods();\n" +
// " for (int i = 0; i < tabM.length; i++) {\n" +
// " String scope = Modifier.toString(tabM[i].getModifiers());\n" +
// " if (scope.startsWith(\"public\") && !\"wait\".equals(tabM[i].getName()) && !\"notifyall\".equals(tabM[i].getName().toLowerCase()) && !\"notify\".equals(tabM[i].getName().toLowerCase()) && !\"getclass\".equals(tabM[i].getName().toLowerCase()) && !\"equals\".equals(tabM[i].getName().toLowerCase()) && !\"tostring\".equals(tabM[i].getName().toLowerCase()) && !\"wait\".equals(tabM[i].getName().toLowerCase()) && !\"hashcode\".equals(tabM[i].getName().toLowerCase())) {\n" +
// " Method m = tabM[i];\n" +
// " EntryPathData entry = new EntryPathData();\n" +
// " entry.setTypePath(TypePath.DYNAMIC);\n" +
// " entry.setClassName(action.getClassName());\n" +
// " entry.setMethodName(m.getName());\n" +
// " entry.setUri(action.getName());\n" +
// " entry.setSignatureName(org.objectweb.asm.Type.getMethodDescriptor(m));\n" +
// " List listEntryPathData = new ArrayList();\n" +
// " for (int j = 0; j < m.getParameterTypes().length; j++) {\n" +
// " EntryPathParam param = new EntryPathParam();\n" +
// " param.setKey(\"\");\n" +
// " param.setTypeParam(TypeParam.PARAM_DATA);\n" +
// " param.setValue(m.getParameterTypes()[j].getName());\n" +
// " listEntryPathData.add(param);\n" +
// " }\n" +
// " entry.setListEntryPathData(listEntryPathData);\n" +
// " listEntryPath.add(entry);\n" +
// " }\n" +
// " }\n" +
// " } catch (ClassNotFoundException e) {\n" +
// " e.printStackTrace();\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " CoreEngine.getInstance().getFramework(\"STRUTS_2\").receiveData(listEntryPath);\n" +
// "}";
// }
// }
//
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String extractBody(String in, String methodName) throws ParseException, FileNotFoundException {
// return extractMethod(JavaParser.parse(new FileInputStream(in)), methodName);
// }
//
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String[] extractPackages(String in) throws ParseException, FileNotFoundException {
// List<String> classes = extractImports(in);
// Set<String> ret = new TreeSet<String>();
// for (String aClass : classes) {
// ret.add(aClass.substring(0, aClass.lastIndexOf(".")));
// }
//
// return ret.toArray(new String[]{});
// }
| import com.github.javaparser.ParseException;
import com.highway2urhell.transformer.Struts2Transformer;
import org.junit.Test;
import java.io.FileNotFoundException;
import static com.highway2urhell.utils.ParsingUtil.extractBody;
import static com.highway2urhell.utils.ParsingUtil.extractPackages;
import static org.fest.assertions.Assertions.assertThat; | package com.highway2urhell.collector;
public class Struts2CollectorTest {
@Test
public void checkScript() throws FileNotFoundException, ParseException {
assertThat(Struts2Transformer.collectBody()) | // Path: h2hell-core/src/main/java/com/highway2urhell/transformer/Struts2Transformer.java
// public class Struts2Transformer extends AbstractLeechTransformer {
//
// public Struts2Transformer() {
// super("org/apache/struts2/dispatcher/ng/filter/StrutsPrepareAndExecuteFilter");
// addImportPackage(collectPackages());
// }
//
// public static String[] collectPackages() {
// return new String[]{
// "com.highway2urhell",
// "com.highway2urhell.domain",
// "com.opensymphony.xwork2.config",
// "com.opensymphony.xwork2.config.entities",
// "java.lang.reflect",
// "java.util",
// "org.apache.struts2.dispatcher"
// };
// }
//
// @Override
// protected void doTransform(CtClass cc) throws Exception {
// CtMethod m = cc
// .getMethod("postInit",
// "(Lorg/apache/struts2/dispatcher/Dispatcher;Ljavax/servlet/FilterConfig;)V");
// m.insertBefore(collectBody());
// }
//
// public static String collectBody() {
// return "{\n" +
// " List listEntryPath = new ArrayList();\n" +
// " ConfigurationManager cm = dispatcher.getConfigurationManager();\n" +
// " Configuration cf = cm.getConfiguration();\n" +
// " Collection colPackages = cf.getPackageConfigs().values();\n" +
// " if (colPackages != null) {\n" +
// " Iterator ite = colPackages.iterator();\n" +
// " while (ite.hasNext()) {\n" +
// " PackageConfig pack = (PackageConfig) ite.next();\n" +
// " Collection colActionConfigs = pack.getActionConfigs().values();\n" +
// " Iterator iteCol = colActionConfigs.iterator();\n" +
// " while (iteCol.hasNext()) {\n" +
// " ActionConfig action = (ActionConfig) iteCol.next();\n" +
// " if (action.getClassName() != null && !\"\".equals(action.getClassName())) {\n" +
// " try {\n" +
// " Class c = Class.forName(action.getClassName());\n" +
// " Method[] tabM = c.getDeclaredMethods();\n" +
// " for (int i = 0; i < tabM.length; i++) {\n" +
// " String scope = Modifier.toString(tabM[i].getModifiers());\n" +
// " if (scope.startsWith(\"public\") && !\"wait\".equals(tabM[i].getName()) && !\"notifyall\".equals(tabM[i].getName().toLowerCase()) && !\"notify\".equals(tabM[i].getName().toLowerCase()) && !\"getclass\".equals(tabM[i].getName().toLowerCase()) && !\"equals\".equals(tabM[i].getName().toLowerCase()) && !\"tostring\".equals(tabM[i].getName().toLowerCase()) && !\"wait\".equals(tabM[i].getName().toLowerCase()) && !\"hashcode\".equals(tabM[i].getName().toLowerCase())) {\n" +
// " Method m = tabM[i];\n" +
// " EntryPathData entry = new EntryPathData();\n" +
// " entry.setTypePath(TypePath.DYNAMIC);\n" +
// " entry.setClassName(action.getClassName());\n" +
// " entry.setMethodName(m.getName());\n" +
// " entry.setUri(action.getName());\n" +
// " entry.setSignatureName(org.objectweb.asm.Type.getMethodDescriptor(m));\n" +
// " List listEntryPathData = new ArrayList();\n" +
// " for (int j = 0; j < m.getParameterTypes().length; j++) {\n" +
// " EntryPathParam param = new EntryPathParam();\n" +
// " param.setKey(\"\");\n" +
// " param.setTypeParam(TypeParam.PARAM_DATA);\n" +
// " param.setValue(m.getParameterTypes()[j].getName());\n" +
// " listEntryPathData.add(param);\n" +
// " }\n" +
// " entry.setListEntryPathData(listEntryPathData);\n" +
// " listEntryPath.add(entry);\n" +
// " }\n" +
// " }\n" +
// " } catch (ClassNotFoundException e) {\n" +
// " e.printStackTrace();\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " }\n" +
// " CoreEngine.getInstance().getFramework(\"STRUTS_2\").receiveData(listEntryPath);\n" +
// "}";
// }
// }
//
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String extractBody(String in, String methodName) throws ParseException, FileNotFoundException {
// return extractMethod(JavaParser.parse(new FileInputStream(in)), methodName);
// }
//
// Path: h2hell-core/src/test/java/com/highway2urhell/utils/ParsingUtil.java
// public static String[] extractPackages(String in) throws ParseException, FileNotFoundException {
// List<String> classes = extractImports(in);
// Set<String> ret = new TreeSet<String>();
// for (String aClass : classes) {
// ret.add(aClass.substring(0, aClass.lastIndexOf(".")));
// }
//
// return ret.toArray(new String[]{});
// }
// Path: h2hell-core/src/test/java/com/highway2urhell/collector/Struts2CollectorTest.java
import com.github.javaparser.ParseException;
import com.highway2urhell.transformer.Struts2Transformer;
import org.junit.Test;
import java.io.FileNotFoundException;
import static com.highway2urhell.utils.ParsingUtil.extractBody;
import static com.highway2urhell.utils.ParsingUtil.extractPackages;
import static org.fest.assertions.Assertions.assertThat;
package com.highway2urhell.collector;
public class Struts2CollectorTest {
@Test
public void checkScript() throws FileNotFoundException, ParseException {
assertThat(Struts2Transformer.collectBody()) | .isEqualTo(extractBody("./src/test/java/com/highway2urhell/collector/Struts2Collector.java", "collectBody")); |
highway-to-urhell/highway-to-urhell | h2hell-core/src/main/java/com/highway2urhell/service/impl/Struts2Service.java | // Path: h2hell-core/src/main/java/com/highway2urhell/VersionUtils.java
// public class VersionUtils {
//
// public static final String UNKNOWN_VERSION = "UNKNOWN";
// public static final String NO_FRAMEWORK = "NO_FRAMEWORK";
//
// private VersionUtils() {
// }
//
// public static String getVersion(String clazzName, String groupId, String artifactId) {
// //check
// Class<?> clazz;
// try {
// clazz = Class.forName(clazzName);
// } catch (ClassNotFoundException e1) {
// return NO_FRAMEWORK;
// }
// String version = null;
//
// // try to load from maven properties first
// Properties p = new Properties();
// InputStream is = null;
//
// try {
// is = clazz.getResourceAsStream("/META-INF/maven/" + groupId + "/" + artifactId + "/pom.properties");
// if (is != null) {
// p.load(is);
// version = p.getProperty("version", "");
// }
// } catch (Exception e) {
// // ignore
// } finally {
// if (is != null) {
// try {
// is.close();
// } catch (IOException e) {
// // ignore
// }
// }
// }
//
// // try to load from manifest
// try {
// URL clazzRes = clazz.getResource('/' + clazz.getName().replace('.', '/') + ".class");
// String classResPath = clazzRes.getPath();
// Manifest manifest = null;
// if (classResPath.contains("!")) {
// classResPath = classResPath.split("!")[0];
// URL url = new URL("jar:" + classResPath + "!/");
// JarURLConnection jarConnection = (JarURLConnection) url.openConnection();
// manifest = jarConnection.getManifest();
// } else {
// is = clazz.getResourceAsStream(classResPath + "!/META-INF/MANIFEST.MF");
// if (is != null)
// manifest = new Manifest(is);
//
// }
// if (manifest != null) {
// Attributes attr = manifest.getMainAttributes();
// version = attr.getValue("Implementation-Version");
// }
// } catch (Exception e) {
// // ignore
// } finally {
// if (is != null) {
// try {
// is.close();
// } catch (IOException e) {
// // ignore
// }
// }
// }
//
//
// // fallback to using Java API
// if (version == null) {
// Package aPackage = clazz.getPackage();
// if (aPackage != null) {
// version = aPackage.getImplementationVersion();
// if (version == null) {
// version = aPackage.getSpecificationVersion();
// }
// }
// }
// if (version == null) {
// // we could not compute the version so use a blank
// version = UNKNOWN_VERSION;
// }
//
// return version;
// }
//
// }
//
// Path: h2hell-core/src/main/java/com/highway2urhell/service/AbstractLeechService.java
// public abstract class AbstractLeechService implements LeechService {
//
// private FrameworkInformations frameworkInformations = new FrameworkInformations();
// private boolean triggeredAtStartup = false;
//
// public AbstractLeechService(String frameworkName) {
// frameworkInformations.setFrameworkName(frameworkName);
// }
//
// public AbstractLeechService(String frameworkName, String version) {
// this(frameworkName);
// frameworkInformations.setVersion(version);
// }
//
// @Override
// public boolean isTriggeredAtStartup() {
// return triggeredAtStartup;
// }
//
// protected void setTriggerAtStartup(boolean triggeredAtStartup) {
// this.triggeredAtStartup = triggeredAtStartup;
// }
//
// public void receiveData(List<EntryPathData> incoming) {
// clearPreviousData();
// System.out.println("receive incoming data obj "+ incoming+ "for framework "+frameworkInformations.getFrameworkName());
// gatherData(incoming);
// System.out.println("data gathering complete. Found entries "+frameworkInformations.getListEntryPath().size());
// }
//
// private void clearPreviousData() {
// frameworkInformations.getListEntryPath().clear();
// }
//
//
// protected void gatherData(List<EntryPathData> incoming) {
// List<EntryPathData> listEntryPath = incoming;
// for (EntryPathData entry : listEntryPath) {
// if (entry.getMethodName() != null && !entry.getMethodName().contains("$")) {
// addEntryPath(entry);
// }
// }
// }
//
// @Override
// public FrameworkInformations getFrameworkInformations() {
// return frameworkInformations;
// }
//
// protected void addEntryPath(EntryPathData entryPath) {
// frameworkInformations.getListEntryPath().add(entryPath);
// }
//
// public String getInternalSignature(String className, String methodName) {
// String res = "";
// try {
// Class<?> c = Class.forName(className);
// for (Method m : c.getDeclaredMethods()) {
// if (m.getName().equals(methodName)) {
// res = Type.getMethodDescriptor(m);
// }
// }
//
// } catch (ClassNotFoundException e) {
// System.err.println("Can't construct classname " + className+" : "+ e);
// }
//
// return res;
// }
//
// public String getInternalSignature(Method m) {
// return Type.getMethodDescriptor(m);
// }
// }
| import com.highway2urhell.VersionUtils;
import com.highway2urhell.service.AbstractLeechService; | package com.highway2urhell.service.impl;
public class Struts2Service extends AbstractLeechService {
public static final String FRAMEWORK_NAME = "STRUTS_2";
public Struts2Service() { | // Path: h2hell-core/src/main/java/com/highway2urhell/VersionUtils.java
// public class VersionUtils {
//
// public static final String UNKNOWN_VERSION = "UNKNOWN";
// public static final String NO_FRAMEWORK = "NO_FRAMEWORK";
//
// private VersionUtils() {
// }
//
// public static String getVersion(String clazzName, String groupId, String artifactId) {
// //check
// Class<?> clazz;
// try {
// clazz = Class.forName(clazzName);
// } catch (ClassNotFoundException e1) {
// return NO_FRAMEWORK;
// }
// String version = null;
//
// // try to load from maven properties first
// Properties p = new Properties();
// InputStream is = null;
//
// try {
// is = clazz.getResourceAsStream("/META-INF/maven/" + groupId + "/" + artifactId + "/pom.properties");
// if (is != null) {
// p.load(is);
// version = p.getProperty("version", "");
// }
// } catch (Exception e) {
// // ignore
// } finally {
// if (is != null) {
// try {
// is.close();
// } catch (IOException e) {
// // ignore
// }
// }
// }
//
// // try to load from manifest
// try {
// URL clazzRes = clazz.getResource('/' + clazz.getName().replace('.', '/') + ".class");
// String classResPath = clazzRes.getPath();
// Manifest manifest = null;
// if (classResPath.contains("!")) {
// classResPath = classResPath.split("!")[0];
// URL url = new URL("jar:" + classResPath + "!/");
// JarURLConnection jarConnection = (JarURLConnection) url.openConnection();
// manifest = jarConnection.getManifest();
// } else {
// is = clazz.getResourceAsStream(classResPath + "!/META-INF/MANIFEST.MF");
// if (is != null)
// manifest = new Manifest(is);
//
// }
// if (manifest != null) {
// Attributes attr = manifest.getMainAttributes();
// version = attr.getValue("Implementation-Version");
// }
// } catch (Exception e) {
// // ignore
// } finally {
// if (is != null) {
// try {
// is.close();
// } catch (IOException e) {
// // ignore
// }
// }
// }
//
//
// // fallback to using Java API
// if (version == null) {
// Package aPackage = clazz.getPackage();
// if (aPackage != null) {
// version = aPackage.getImplementationVersion();
// if (version == null) {
// version = aPackage.getSpecificationVersion();
// }
// }
// }
// if (version == null) {
// // we could not compute the version so use a blank
// version = UNKNOWN_VERSION;
// }
//
// return version;
// }
//
// }
//
// Path: h2hell-core/src/main/java/com/highway2urhell/service/AbstractLeechService.java
// public abstract class AbstractLeechService implements LeechService {
//
// private FrameworkInformations frameworkInformations = new FrameworkInformations();
// private boolean triggeredAtStartup = false;
//
// public AbstractLeechService(String frameworkName) {
// frameworkInformations.setFrameworkName(frameworkName);
// }
//
// public AbstractLeechService(String frameworkName, String version) {
// this(frameworkName);
// frameworkInformations.setVersion(version);
// }
//
// @Override
// public boolean isTriggeredAtStartup() {
// return triggeredAtStartup;
// }
//
// protected void setTriggerAtStartup(boolean triggeredAtStartup) {
// this.triggeredAtStartup = triggeredAtStartup;
// }
//
// public void receiveData(List<EntryPathData> incoming) {
// clearPreviousData();
// System.out.println("receive incoming data obj "+ incoming+ "for framework "+frameworkInformations.getFrameworkName());
// gatherData(incoming);
// System.out.println("data gathering complete. Found entries "+frameworkInformations.getListEntryPath().size());
// }
//
// private void clearPreviousData() {
// frameworkInformations.getListEntryPath().clear();
// }
//
//
// protected void gatherData(List<EntryPathData> incoming) {
// List<EntryPathData> listEntryPath = incoming;
// for (EntryPathData entry : listEntryPath) {
// if (entry.getMethodName() != null && !entry.getMethodName().contains("$")) {
// addEntryPath(entry);
// }
// }
// }
//
// @Override
// public FrameworkInformations getFrameworkInformations() {
// return frameworkInformations;
// }
//
// protected void addEntryPath(EntryPathData entryPath) {
// frameworkInformations.getListEntryPath().add(entryPath);
// }
//
// public String getInternalSignature(String className, String methodName) {
// String res = "";
// try {
// Class<?> c = Class.forName(className);
// for (Method m : c.getDeclaredMethods()) {
// if (m.getName().equals(methodName)) {
// res = Type.getMethodDescriptor(m);
// }
// }
//
// } catch (ClassNotFoundException e) {
// System.err.println("Can't construct classname " + className+" : "+ e);
// }
//
// return res;
// }
//
// public String getInternalSignature(Method m) {
// return Type.getMethodDescriptor(m);
// }
// }
// Path: h2hell-core/src/main/java/com/highway2urhell/service/impl/Struts2Service.java
import com.highway2urhell.VersionUtils;
import com.highway2urhell.service.AbstractLeechService;
package com.highway2urhell.service.impl;
public class Struts2Service extends AbstractLeechService {
public static final String FRAMEWORK_NAME = "STRUTS_2";
public Struts2Service() { | super(FRAMEWORK_NAME, VersionUtils.getVersion( |
highway-to-urhell/highway-to-urhell | h2hell-core/src/main/java/com/highway2urhell/service/impl/JSF2Service.java | // Path: h2hell-core/src/main/java/com/highway2urhell/VersionUtils.java
// public class VersionUtils {
//
// public static final String UNKNOWN_VERSION = "UNKNOWN";
// public static final String NO_FRAMEWORK = "NO_FRAMEWORK";
//
// private VersionUtils() {
// }
//
// public static String getVersion(String clazzName, String groupId, String artifactId) {
// //check
// Class<?> clazz;
// try {
// clazz = Class.forName(clazzName);
// } catch (ClassNotFoundException e1) {
// return NO_FRAMEWORK;
// }
// String version = null;
//
// // try to load from maven properties first
// Properties p = new Properties();
// InputStream is = null;
//
// try {
// is = clazz.getResourceAsStream("/META-INF/maven/" + groupId + "/" + artifactId + "/pom.properties");
// if (is != null) {
// p.load(is);
// version = p.getProperty("version", "");
// }
// } catch (Exception e) {
// // ignore
// } finally {
// if (is != null) {
// try {
// is.close();
// } catch (IOException e) {
// // ignore
// }
// }
// }
//
// // try to load from manifest
// try {
// URL clazzRes = clazz.getResource('/' + clazz.getName().replace('.', '/') + ".class");
// String classResPath = clazzRes.getPath();
// Manifest manifest = null;
// if (classResPath.contains("!")) {
// classResPath = classResPath.split("!")[0];
// URL url = new URL("jar:" + classResPath + "!/");
// JarURLConnection jarConnection = (JarURLConnection) url.openConnection();
// manifest = jarConnection.getManifest();
// } else {
// is = clazz.getResourceAsStream(classResPath + "!/META-INF/MANIFEST.MF");
// if (is != null)
// manifest = new Manifest(is);
//
// }
// if (manifest != null) {
// Attributes attr = manifest.getMainAttributes();
// version = attr.getValue("Implementation-Version");
// }
// } catch (Exception e) {
// // ignore
// } finally {
// if (is != null) {
// try {
// is.close();
// } catch (IOException e) {
// // ignore
// }
// }
// }
//
//
// // fallback to using Java API
// if (version == null) {
// Package aPackage = clazz.getPackage();
// if (aPackage != null) {
// version = aPackage.getImplementationVersion();
// if (version == null) {
// version = aPackage.getSpecificationVersion();
// }
// }
// }
// if (version == null) {
// // we could not compute the version so use a blank
// version = UNKNOWN_VERSION;
// }
//
// return version;
// }
//
// }
//
// Path: h2hell-core/src/main/java/com/highway2urhell/service/AbstractLeechService.java
// public abstract class AbstractLeechService implements LeechService {
//
// private FrameworkInformations frameworkInformations = new FrameworkInformations();
// private boolean triggeredAtStartup = false;
//
// public AbstractLeechService(String frameworkName) {
// frameworkInformations.setFrameworkName(frameworkName);
// }
//
// public AbstractLeechService(String frameworkName, String version) {
// this(frameworkName);
// frameworkInformations.setVersion(version);
// }
//
// @Override
// public boolean isTriggeredAtStartup() {
// return triggeredAtStartup;
// }
//
// protected void setTriggerAtStartup(boolean triggeredAtStartup) {
// this.triggeredAtStartup = triggeredAtStartup;
// }
//
// public void receiveData(List<EntryPathData> incoming) {
// clearPreviousData();
// System.out.println("receive incoming data obj "+ incoming+ "for framework "+frameworkInformations.getFrameworkName());
// gatherData(incoming);
// System.out.println("data gathering complete. Found entries "+frameworkInformations.getListEntryPath().size());
// }
//
// private void clearPreviousData() {
// frameworkInformations.getListEntryPath().clear();
// }
//
//
// protected void gatherData(List<EntryPathData> incoming) {
// List<EntryPathData> listEntryPath = incoming;
// for (EntryPathData entry : listEntryPath) {
// if (entry.getMethodName() != null && !entry.getMethodName().contains("$")) {
// addEntryPath(entry);
// }
// }
// }
//
// @Override
// public FrameworkInformations getFrameworkInformations() {
// return frameworkInformations;
// }
//
// protected void addEntryPath(EntryPathData entryPath) {
// frameworkInformations.getListEntryPath().add(entryPath);
// }
//
// public String getInternalSignature(String className, String methodName) {
// String res = "";
// try {
// Class<?> c = Class.forName(className);
// for (Method m : c.getDeclaredMethods()) {
// if (m.getName().equals(methodName)) {
// res = Type.getMethodDescriptor(m);
// }
// }
//
// } catch (ClassNotFoundException e) {
// System.err.println("Can't construct classname " + className+" : "+ e);
// }
//
// return res;
// }
//
// public String getInternalSignature(Method m) {
// return Type.getMethodDescriptor(m);
// }
// }
| import com.highway2urhell.VersionUtils;
import com.highway2urhell.service.AbstractLeechService; | package com.highway2urhell.service.impl;
public class JSF2Service extends AbstractLeechService {
public static final String FRAMEWORK_NAME = "JSF_2";
public JSF2Service() { | // Path: h2hell-core/src/main/java/com/highway2urhell/VersionUtils.java
// public class VersionUtils {
//
// public static final String UNKNOWN_VERSION = "UNKNOWN";
// public static final String NO_FRAMEWORK = "NO_FRAMEWORK";
//
// private VersionUtils() {
// }
//
// public static String getVersion(String clazzName, String groupId, String artifactId) {
// //check
// Class<?> clazz;
// try {
// clazz = Class.forName(clazzName);
// } catch (ClassNotFoundException e1) {
// return NO_FRAMEWORK;
// }
// String version = null;
//
// // try to load from maven properties first
// Properties p = new Properties();
// InputStream is = null;
//
// try {
// is = clazz.getResourceAsStream("/META-INF/maven/" + groupId + "/" + artifactId + "/pom.properties");
// if (is != null) {
// p.load(is);
// version = p.getProperty("version", "");
// }
// } catch (Exception e) {
// // ignore
// } finally {
// if (is != null) {
// try {
// is.close();
// } catch (IOException e) {
// // ignore
// }
// }
// }
//
// // try to load from manifest
// try {
// URL clazzRes = clazz.getResource('/' + clazz.getName().replace('.', '/') + ".class");
// String classResPath = clazzRes.getPath();
// Manifest manifest = null;
// if (classResPath.contains("!")) {
// classResPath = classResPath.split("!")[0];
// URL url = new URL("jar:" + classResPath + "!/");
// JarURLConnection jarConnection = (JarURLConnection) url.openConnection();
// manifest = jarConnection.getManifest();
// } else {
// is = clazz.getResourceAsStream(classResPath + "!/META-INF/MANIFEST.MF");
// if (is != null)
// manifest = new Manifest(is);
//
// }
// if (manifest != null) {
// Attributes attr = manifest.getMainAttributes();
// version = attr.getValue("Implementation-Version");
// }
// } catch (Exception e) {
// // ignore
// } finally {
// if (is != null) {
// try {
// is.close();
// } catch (IOException e) {
// // ignore
// }
// }
// }
//
//
// // fallback to using Java API
// if (version == null) {
// Package aPackage = clazz.getPackage();
// if (aPackage != null) {
// version = aPackage.getImplementationVersion();
// if (version == null) {
// version = aPackage.getSpecificationVersion();
// }
// }
// }
// if (version == null) {
// // we could not compute the version so use a blank
// version = UNKNOWN_VERSION;
// }
//
// return version;
// }
//
// }
//
// Path: h2hell-core/src/main/java/com/highway2urhell/service/AbstractLeechService.java
// public abstract class AbstractLeechService implements LeechService {
//
// private FrameworkInformations frameworkInformations = new FrameworkInformations();
// private boolean triggeredAtStartup = false;
//
// public AbstractLeechService(String frameworkName) {
// frameworkInformations.setFrameworkName(frameworkName);
// }
//
// public AbstractLeechService(String frameworkName, String version) {
// this(frameworkName);
// frameworkInformations.setVersion(version);
// }
//
// @Override
// public boolean isTriggeredAtStartup() {
// return triggeredAtStartup;
// }
//
// protected void setTriggerAtStartup(boolean triggeredAtStartup) {
// this.triggeredAtStartup = triggeredAtStartup;
// }
//
// public void receiveData(List<EntryPathData> incoming) {
// clearPreviousData();
// System.out.println("receive incoming data obj "+ incoming+ "for framework "+frameworkInformations.getFrameworkName());
// gatherData(incoming);
// System.out.println("data gathering complete. Found entries "+frameworkInformations.getListEntryPath().size());
// }
//
// private void clearPreviousData() {
// frameworkInformations.getListEntryPath().clear();
// }
//
//
// protected void gatherData(List<EntryPathData> incoming) {
// List<EntryPathData> listEntryPath = incoming;
// for (EntryPathData entry : listEntryPath) {
// if (entry.getMethodName() != null && !entry.getMethodName().contains("$")) {
// addEntryPath(entry);
// }
// }
// }
//
// @Override
// public FrameworkInformations getFrameworkInformations() {
// return frameworkInformations;
// }
//
// protected void addEntryPath(EntryPathData entryPath) {
// frameworkInformations.getListEntryPath().add(entryPath);
// }
//
// public String getInternalSignature(String className, String methodName) {
// String res = "";
// try {
// Class<?> c = Class.forName(className);
// for (Method m : c.getDeclaredMethods()) {
// if (m.getName().equals(methodName)) {
// res = Type.getMethodDescriptor(m);
// }
// }
//
// } catch (ClassNotFoundException e) {
// System.err.println("Can't construct classname " + className+" : "+ e);
// }
//
// return res;
// }
//
// public String getInternalSignature(Method m) {
// return Type.getMethodDescriptor(m);
// }
// }
// Path: h2hell-core/src/main/java/com/highway2urhell/service/impl/JSF2Service.java
import com.highway2urhell.VersionUtils;
import com.highway2urhell.service.AbstractLeechService;
package com.highway2urhell.service.impl;
public class JSF2Service extends AbstractLeechService {
public static final String FRAMEWORK_NAME = "JSF_2";
public JSF2Service() { | super(FRAMEWORK_NAME, VersionUtils.getVersion( |
highway-to-urhell/highway-to-urhell | h2hell-core/src/main/java/com/highway2urhell/service/LeechService.java | // Path: h2hell-core/src/main/java/com/highway2urhell/domain/EntryPathData.java
// public class EntryPathData {
// private String uri;
// private String methodName;
// private String className;
// private String classNameNormalized;
// private String signatureName;
// private TypePath typePath = TypePath.UNKNOWN;
// private Boolean audit = true;
// private String httpMethod = "";
// private List<EntryPathParam> listEntryPathData = new ArrayList<EntryPathParam>();
// private Integer lineNumber;
//
// public Integer getLineNumber() {
// return lineNumber;
// }
//
// public void setLineNumber(Integer lineNumber) {
// this.lineNumber = lineNumber;
// }
//
// public Boolean getAudit() {
// return audit;
// }
//
// public void setAudit(Boolean audit) {
// this.audit = audit;
// }
//
// public String getUri() {
// return uri;
// }
//
// public void setUri(String uri) {
// this.uri = uri;
// }
//
// public String getMethodName() {
// return methodName;
// }
//
// public void setMethodName(String methodName) {
// this.methodName = methodName;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
//
// public String getClassNameNormalized() {
// return classNameNormalized;
// }
//
// public void setClassNameNormalized(String classNameNormalized) {
// this.classNameNormalized = classNameNormalized;
// }
//
// public String getSignatureName() {
// return signatureName;
// }
//
// public void setSignatureName(String signatureName) {
// this.signatureName = signatureName;
// }
//
// public TypePath getTypePath() {
// return typePath;
// }
//
// public void setTypePath(TypePath typePath) {
// this.typePath = typePath;
// }
//
// public String getHttpMethod() {
// return httpMethod;
// }
//
// public void setHttpMethod(String httpMethod) {
// this.httpMethod = httpMethod;
// }
//
// public List<EntryPathParam> getListEntryPathData() {
// return listEntryPathData;
// }
//
// public void setListEntryPathData(List<EntryPathParam> listEntryPathData) {
// this.listEntryPathData = listEntryPathData;
// }
//
// @Override
// public String toString() {
// return "EntryPathData [uri=" + uri + ", methodName=" + methodName
// + ", className=" + className + ", classNameNormalized="
// + classNameNormalized + ", signatureName=" + signatureName
// + ", typePath=" + typePath + ", httpMethod=" + httpMethod
// + "]";
// }
// }
//
// Path: h2hell-core/src/main/java/com/highway2urhell/domain/FrameworkInformations.java
// public class FrameworkInformations {
//
// private String frameworkName;
// private String version = "UNKNOWN";
// private String details;
// private List<EntryPathData> listEntryPath = new ArrayList<EntryPathData>();
//
// public String getFrameworkName() {
// return frameworkName;
// }
//
// public void setFrameworkName(String frameworkName) {
// this.frameworkName = frameworkName;
// }
//
// public String getVersion() {
// return version;
// }
//
// public void setVersion(String version) {
// this.version = version;
// }
//
// public String getDetails() {
// return details;
// }
//
// public void setDetails(String details) {
// this.details = details;
// }
//
// public List<EntryPathData> getListEntryPath() {
// return listEntryPath;
// }
//
// public void setListEntryPath(List<EntryPathData> listEntryPath) {
// this.listEntryPath = listEntryPath;
// }
//
// public boolean hasEntryPaths() {
// return !listEntryPath.isEmpty();
// }
//
// @Override
// public String toString() {
// return "FrameworkInformations [frameworkName=" + frameworkName
// + ", version=" + version + ", details=" + details
// + ", listEntryPath=" + listEntryPath + "]";
// }
//
// }
| import com.highway2urhell.domain.EntryPathData;
import com.highway2urhell.domain.FrameworkInformations;
import java.util.List; | package com.highway2urhell.service;
public interface LeechService {
void receiveData(List<EntryPathData> incoming);
| // Path: h2hell-core/src/main/java/com/highway2urhell/domain/EntryPathData.java
// public class EntryPathData {
// private String uri;
// private String methodName;
// private String className;
// private String classNameNormalized;
// private String signatureName;
// private TypePath typePath = TypePath.UNKNOWN;
// private Boolean audit = true;
// private String httpMethod = "";
// private List<EntryPathParam> listEntryPathData = new ArrayList<EntryPathParam>();
// private Integer lineNumber;
//
// public Integer getLineNumber() {
// return lineNumber;
// }
//
// public void setLineNumber(Integer lineNumber) {
// this.lineNumber = lineNumber;
// }
//
// public Boolean getAudit() {
// return audit;
// }
//
// public void setAudit(Boolean audit) {
// this.audit = audit;
// }
//
// public String getUri() {
// return uri;
// }
//
// public void setUri(String uri) {
// this.uri = uri;
// }
//
// public String getMethodName() {
// return methodName;
// }
//
// public void setMethodName(String methodName) {
// this.methodName = methodName;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
//
// public String getClassNameNormalized() {
// return classNameNormalized;
// }
//
// public void setClassNameNormalized(String classNameNormalized) {
// this.classNameNormalized = classNameNormalized;
// }
//
// public String getSignatureName() {
// return signatureName;
// }
//
// public void setSignatureName(String signatureName) {
// this.signatureName = signatureName;
// }
//
// public TypePath getTypePath() {
// return typePath;
// }
//
// public void setTypePath(TypePath typePath) {
// this.typePath = typePath;
// }
//
// public String getHttpMethod() {
// return httpMethod;
// }
//
// public void setHttpMethod(String httpMethod) {
// this.httpMethod = httpMethod;
// }
//
// public List<EntryPathParam> getListEntryPathData() {
// return listEntryPathData;
// }
//
// public void setListEntryPathData(List<EntryPathParam> listEntryPathData) {
// this.listEntryPathData = listEntryPathData;
// }
//
// @Override
// public String toString() {
// return "EntryPathData [uri=" + uri + ", methodName=" + methodName
// + ", className=" + className + ", classNameNormalized="
// + classNameNormalized + ", signatureName=" + signatureName
// + ", typePath=" + typePath + ", httpMethod=" + httpMethod
// + "]";
// }
// }
//
// Path: h2hell-core/src/main/java/com/highway2urhell/domain/FrameworkInformations.java
// public class FrameworkInformations {
//
// private String frameworkName;
// private String version = "UNKNOWN";
// private String details;
// private List<EntryPathData> listEntryPath = new ArrayList<EntryPathData>();
//
// public String getFrameworkName() {
// return frameworkName;
// }
//
// public void setFrameworkName(String frameworkName) {
// this.frameworkName = frameworkName;
// }
//
// public String getVersion() {
// return version;
// }
//
// public void setVersion(String version) {
// this.version = version;
// }
//
// public String getDetails() {
// return details;
// }
//
// public void setDetails(String details) {
// this.details = details;
// }
//
// public List<EntryPathData> getListEntryPath() {
// return listEntryPath;
// }
//
// public void setListEntryPath(List<EntryPathData> listEntryPath) {
// this.listEntryPath = listEntryPath;
// }
//
// public boolean hasEntryPaths() {
// return !listEntryPath.isEmpty();
// }
//
// @Override
// public String toString() {
// return "FrameworkInformations [frameworkName=" + frameworkName
// + ", version=" + version + ", details=" + details
// + ", listEntryPath=" + listEntryPath + "]";
// }
//
// }
// Path: h2hell-core/src/main/java/com/highway2urhell/service/LeechService.java
import com.highway2urhell.domain.EntryPathData;
import com.highway2urhell.domain.FrameworkInformations;
import java.util.List;
package com.highway2urhell.service;
public interface LeechService {
void receiveData(List<EntryPathData> incoming);
| FrameworkInformations getFrameworkInformations(); |
highway-to-urhell/highway-to-urhell | h2hell-core/src/main/java/com/highway2urhell/service/impl/ActiveMQConnectionFactoryService.java | // Path: h2hell-core/src/main/java/com/highway2urhell/VersionUtils.java
// public class VersionUtils {
//
// public static final String UNKNOWN_VERSION = "UNKNOWN";
// public static final String NO_FRAMEWORK = "NO_FRAMEWORK";
//
// private VersionUtils() {
// }
//
// public static String getVersion(String clazzName, String groupId, String artifactId) {
// //check
// Class<?> clazz;
// try {
// clazz = Class.forName(clazzName);
// } catch (ClassNotFoundException e1) {
// return NO_FRAMEWORK;
// }
// String version = null;
//
// // try to load from maven properties first
// Properties p = new Properties();
// InputStream is = null;
//
// try {
// is = clazz.getResourceAsStream("/META-INF/maven/" + groupId + "/" + artifactId + "/pom.properties");
// if (is != null) {
// p.load(is);
// version = p.getProperty("version", "");
// }
// } catch (Exception e) {
// // ignore
// } finally {
// if (is != null) {
// try {
// is.close();
// } catch (IOException e) {
// // ignore
// }
// }
// }
//
// // try to load from manifest
// try {
// URL clazzRes = clazz.getResource('/' + clazz.getName().replace('.', '/') + ".class");
// String classResPath = clazzRes.getPath();
// Manifest manifest = null;
// if (classResPath.contains("!")) {
// classResPath = classResPath.split("!")[0];
// URL url = new URL("jar:" + classResPath + "!/");
// JarURLConnection jarConnection = (JarURLConnection) url.openConnection();
// manifest = jarConnection.getManifest();
// } else {
// is = clazz.getResourceAsStream(classResPath + "!/META-INF/MANIFEST.MF");
// if (is != null)
// manifest = new Manifest(is);
//
// }
// if (manifest != null) {
// Attributes attr = manifest.getMainAttributes();
// version = attr.getValue("Implementation-Version");
// }
// } catch (Exception e) {
// // ignore
// } finally {
// if (is != null) {
// try {
// is.close();
// } catch (IOException e) {
// // ignore
// }
// }
// }
//
//
// // fallback to using Java API
// if (version == null) {
// Package aPackage = clazz.getPackage();
// if (aPackage != null) {
// version = aPackage.getImplementationVersion();
// if (version == null) {
// version = aPackage.getSpecificationVersion();
// }
// }
// }
// if (version == null) {
// // we could not compute the version so use a blank
// version = UNKNOWN_VERSION;
// }
//
// return version;
// }
//
// }
//
// Path: h2hell-core/src/main/java/com/highway2urhell/service/AbstractLeechService.java
// public abstract class AbstractLeechService implements LeechService {
//
// private FrameworkInformations frameworkInformations = new FrameworkInformations();
// private boolean triggeredAtStartup = false;
//
// public AbstractLeechService(String frameworkName) {
// frameworkInformations.setFrameworkName(frameworkName);
// }
//
// public AbstractLeechService(String frameworkName, String version) {
// this(frameworkName);
// frameworkInformations.setVersion(version);
// }
//
// @Override
// public boolean isTriggeredAtStartup() {
// return triggeredAtStartup;
// }
//
// protected void setTriggerAtStartup(boolean triggeredAtStartup) {
// this.triggeredAtStartup = triggeredAtStartup;
// }
//
// public void receiveData(List<EntryPathData> incoming) {
// clearPreviousData();
// System.out.println("receive incoming data obj "+ incoming+ "for framework "+frameworkInformations.getFrameworkName());
// gatherData(incoming);
// System.out.println("data gathering complete. Found entries "+frameworkInformations.getListEntryPath().size());
// }
//
// private void clearPreviousData() {
// frameworkInformations.getListEntryPath().clear();
// }
//
//
// protected void gatherData(List<EntryPathData> incoming) {
// List<EntryPathData> listEntryPath = incoming;
// for (EntryPathData entry : listEntryPath) {
// if (entry.getMethodName() != null && !entry.getMethodName().contains("$")) {
// addEntryPath(entry);
// }
// }
// }
//
// @Override
// public FrameworkInformations getFrameworkInformations() {
// return frameworkInformations;
// }
//
// protected void addEntryPath(EntryPathData entryPath) {
// frameworkInformations.getListEntryPath().add(entryPath);
// }
//
// public String getInternalSignature(String className, String methodName) {
// String res = "";
// try {
// Class<?> c = Class.forName(className);
// for (Method m : c.getDeclaredMethods()) {
// if (m.getName().equals(methodName)) {
// res = Type.getMethodDescriptor(m);
// }
// }
//
// } catch (ClassNotFoundException e) {
// System.err.println("Can't construct classname " + className+" : "+ e);
// }
//
// return res;
// }
//
// public String getInternalSignature(Method m) {
// return Type.getMethodDescriptor(m);
// }
// }
| import com.highway2urhell.VersionUtils;
import com.highway2urhell.service.AbstractLeechService; | package com.highway2urhell.service.impl;
public class ActiveMQConnectionFactoryService extends AbstractLeechService {
public static final String FRAMEWORK_NAME = "ACTIVEMQ_CONNECTION_FACTORY";
public ActiveMQConnectionFactoryService() { | // Path: h2hell-core/src/main/java/com/highway2urhell/VersionUtils.java
// public class VersionUtils {
//
// public static final String UNKNOWN_VERSION = "UNKNOWN";
// public static final String NO_FRAMEWORK = "NO_FRAMEWORK";
//
// private VersionUtils() {
// }
//
// public static String getVersion(String clazzName, String groupId, String artifactId) {
// //check
// Class<?> clazz;
// try {
// clazz = Class.forName(clazzName);
// } catch (ClassNotFoundException e1) {
// return NO_FRAMEWORK;
// }
// String version = null;
//
// // try to load from maven properties first
// Properties p = new Properties();
// InputStream is = null;
//
// try {
// is = clazz.getResourceAsStream("/META-INF/maven/" + groupId + "/" + artifactId + "/pom.properties");
// if (is != null) {
// p.load(is);
// version = p.getProperty("version", "");
// }
// } catch (Exception e) {
// // ignore
// } finally {
// if (is != null) {
// try {
// is.close();
// } catch (IOException e) {
// // ignore
// }
// }
// }
//
// // try to load from manifest
// try {
// URL clazzRes = clazz.getResource('/' + clazz.getName().replace('.', '/') + ".class");
// String classResPath = clazzRes.getPath();
// Manifest manifest = null;
// if (classResPath.contains("!")) {
// classResPath = classResPath.split("!")[0];
// URL url = new URL("jar:" + classResPath + "!/");
// JarURLConnection jarConnection = (JarURLConnection) url.openConnection();
// manifest = jarConnection.getManifest();
// } else {
// is = clazz.getResourceAsStream(classResPath + "!/META-INF/MANIFEST.MF");
// if (is != null)
// manifest = new Manifest(is);
//
// }
// if (manifest != null) {
// Attributes attr = manifest.getMainAttributes();
// version = attr.getValue("Implementation-Version");
// }
// } catch (Exception e) {
// // ignore
// } finally {
// if (is != null) {
// try {
// is.close();
// } catch (IOException e) {
// // ignore
// }
// }
// }
//
//
// // fallback to using Java API
// if (version == null) {
// Package aPackage = clazz.getPackage();
// if (aPackage != null) {
// version = aPackage.getImplementationVersion();
// if (version == null) {
// version = aPackage.getSpecificationVersion();
// }
// }
// }
// if (version == null) {
// // we could not compute the version so use a blank
// version = UNKNOWN_VERSION;
// }
//
// return version;
// }
//
// }
//
// Path: h2hell-core/src/main/java/com/highway2urhell/service/AbstractLeechService.java
// public abstract class AbstractLeechService implements LeechService {
//
// private FrameworkInformations frameworkInformations = new FrameworkInformations();
// private boolean triggeredAtStartup = false;
//
// public AbstractLeechService(String frameworkName) {
// frameworkInformations.setFrameworkName(frameworkName);
// }
//
// public AbstractLeechService(String frameworkName, String version) {
// this(frameworkName);
// frameworkInformations.setVersion(version);
// }
//
// @Override
// public boolean isTriggeredAtStartup() {
// return triggeredAtStartup;
// }
//
// protected void setTriggerAtStartup(boolean triggeredAtStartup) {
// this.triggeredAtStartup = triggeredAtStartup;
// }
//
// public void receiveData(List<EntryPathData> incoming) {
// clearPreviousData();
// System.out.println("receive incoming data obj "+ incoming+ "for framework "+frameworkInformations.getFrameworkName());
// gatherData(incoming);
// System.out.println("data gathering complete. Found entries "+frameworkInformations.getListEntryPath().size());
// }
//
// private void clearPreviousData() {
// frameworkInformations.getListEntryPath().clear();
// }
//
//
// protected void gatherData(List<EntryPathData> incoming) {
// List<EntryPathData> listEntryPath = incoming;
// for (EntryPathData entry : listEntryPath) {
// if (entry.getMethodName() != null && !entry.getMethodName().contains("$")) {
// addEntryPath(entry);
// }
// }
// }
//
// @Override
// public FrameworkInformations getFrameworkInformations() {
// return frameworkInformations;
// }
//
// protected void addEntryPath(EntryPathData entryPath) {
// frameworkInformations.getListEntryPath().add(entryPath);
// }
//
// public String getInternalSignature(String className, String methodName) {
// String res = "";
// try {
// Class<?> c = Class.forName(className);
// for (Method m : c.getDeclaredMethods()) {
// if (m.getName().equals(methodName)) {
// res = Type.getMethodDescriptor(m);
// }
// }
//
// } catch (ClassNotFoundException e) {
// System.err.println("Can't construct classname " + className+" : "+ e);
// }
//
// return res;
// }
//
// public String getInternalSignature(Method m) {
// return Type.getMethodDescriptor(m);
// }
// }
// Path: h2hell-core/src/main/java/com/highway2urhell/service/impl/ActiveMQConnectionFactoryService.java
import com.highway2urhell.VersionUtils;
import com.highway2urhell.service.AbstractLeechService;
package com.highway2urhell.service.impl;
public class ActiveMQConnectionFactoryService extends AbstractLeechService {
public static final String FRAMEWORK_NAME = "ACTIVEMQ_CONNECTION_FACTORY";
public ActiveMQConnectionFactoryService() { | super(FRAMEWORK_NAME, VersionUtils.getVersion( |
highway-to-urhell/highway-to-urhell | h2hell-core/src/main/java/com/highway2urhell/service/impl/PortService.java | // Path: h2hell-core/src/main/java/com/highway2urhell/domain/EntryPathData.java
// public class EntryPathData {
// private String uri;
// private String methodName;
// private String className;
// private String classNameNormalized;
// private String signatureName;
// private TypePath typePath = TypePath.UNKNOWN;
// private Boolean audit = true;
// private String httpMethod = "";
// private List<EntryPathParam> listEntryPathData = new ArrayList<EntryPathParam>();
// private Integer lineNumber;
//
// public Integer getLineNumber() {
// return lineNumber;
// }
//
// public void setLineNumber(Integer lineNumber) {
// this.lineNumber = lineNumber;
// }
//
// public Boolean getAudit() {
// return audit;
// }
//
// public void setAudit(Boolean audit) {
// this.audit = audit;
// }
//
// public String getUri() {
// return uri;
// }
//
// public void setUri(String uri) {
// this.uri = uri;
// }
//
// public String getMethodName() {
// return methodName;
// }
//
// public void setMethodName(String methodName) {
// this.methodName = methodName;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
//
// public String getClassNameNormalized() {
// return classNameNormalized;
// }
//
// public void setClassNameNormalized(String classNameNormalized) {
// this.classNameNormalized = classNameNormalized;
// }
//
// public String getSignatureName() {
// return signatureName;
// }
//
// public void setSignatureName(String signatureName) {
// this.signatureName = signatureName;
// }
//
// public TypePath getTypePath() {
// return typePath;
// }
//
// public void setTypePath(TypePath typePath) {
// this.typePath = typePath;
// }
//
// public String getHttpMethod() {
// return httpMethod;
// }
//
// public void setHttpMethod(String httpMethod) {
// this.httpMethod = httpMethod;
// }
//
// public List<EntryPathParam> getListEntryPathData() {
// return listEntryPathData;
// }
//
// public void setListEntryPathData(List<EntryPathParam> listEntryPathData) {
// this.listEntryPathData = listEntryPathData;
// }
//
// @Override
// public String toString() {
// return "EntryPathData [uri=" + uri + ", methodName=" + methodName
// + ", className=" + className + ", classNameNormalized="
// + classNameNormalized + ", signatureName=" + signatureName
// + ", typePath=" + typePath + ", httpMethod=" + httpMethod
// + "]";
// }
// }
//
// Path: h2hell-core/src/main/java/com/highway2urhell/domain/TypePath.java
// public enum TypePath {
// WEBSERVICE, STATIC, DYNAMIC, SERVLET, FILTER, LISTENER, UNKNOWN
// }
//
// Path: h2hell-core/src/main/java/com/highway2urhell/service/AbstractLeechService.java
// public abstract class AbstractLeechService implements LeechService {
//
// private FrameworkInformations frameworkInformations = new FrameworkInformations();
// private boolean triggeredAtStartup = false;
//
// public AbstractLeechService(String frameworkName) {
// frameworkInformations.setFrameworkName(frameworkName);
// }
//
// public AbstractLeechService(String frameworkName, String version) {
// this(frameworkName);
// frameworkInformations.setVersion(version);
// }
//
// @Override
// public boolean isTriggeredAtStartup() {
// return triggeredAtStartup;
// }
//
// protected void setTriggerAtStartup(boolean triggeredAtStartup) {
// this.triggeredAtStartup = triggeredAtStartup;
// }
//
// public void receiveData(List<EntryPathData> incoming) {
// clearPreviousData();
// System.out.println("receive incoming data obj "+ incoming+ "for framework "+frameworkInformations.getFrameworkName());
// gatherData(incoming);
// System.out.println("data gathering complete. Found entries "+frameworkInformations.getListEntryPath().size());
// }
//
// private void clearPreviousData() {
// frameworkInformations.getListEntryPath().clear();
// }
//
//
// protected void gatherData(List<EntryPathData> incoming) {
// List<EntryPathData> listEntryPath = incoming;
// for (EntryPathData entry : listEntryPath) {
// if (entry.getMethodName() != null && !entry.getMethodName().contains("$")) {
// addEntryPath(entry);
// }
// }
// }
//
// @Override
// public FrameworkInformations getFrameworkInformations() {
// return frameworkInformations;
// }
//
// protected void addEntryPath(EntryPathData entryPath) {
// frameworkInformations.getListEntryPath().add(entryPath);
// }
//
// public String getInternalSignature(String className, String methodName) {
// String res = "";
// try {
// Class<?> c = Class.forName(className);
// for (Method m : c.getDeclaredMethods()) {
// if (m.getName().equals(methodName)) {
// res = Type.getMethodDescriptor(m);
// }
// }
//
// } catch (ClassNotFoundException e) {
// System.err.println("Can't construct classname " + className+" : "+ e);
// }
//
// return res;
// }
//
// public String getInternalSignature(Method m) {
// return Type.getMethodDescriptor(m);
// }
// }
| import com.highway2urhell.domain.EntryPathData;
import com.highway2urhell.domain.TypePath;
import com.highway2urhell.service.AbstractLeechService;
import java.io.IOException;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List; | package com.highway2urhell.service.impl;
public class PortService extends AbstractLeechService {
public static final String FRAMEWORK_NAME = "SYSTEM-PORT";
private static final int MIN_PORT = 1024;
private static final int MAX_PORT = 65535;
public PortService() {
super(FRAMEWORK_NAME);
setTriggerAtStartup(true);
}
@Override | // Path: h2hell-core/src/main/java/com/highway2urhell/domain/EntryPathData.java
// public class EntryPathData {
// private String uri;
// private String methodName;
// private String className;
// private String classNameNormalized;
// private String signatureName;
// private TypePath typePath = TypePath.UNKNOWN;
// private Boolean audit = true;
// private String httpMethod = "";
// private List<EntryPathParam> listEntryPathData = new ArrayList<EntryPathParam>();
// private Integer lineNumber;
//
// public Integer getLineNumber() {
// return lineNumber;
// }
//
// public void setLineNumber(Integer lineNumber) {
// this.lineNumber = lineNumber;
// }
//
// public Boolean getAudit() {
// return audit;
// }
//
// public void setAudit(Boolean audit) {
// this.audit = audit;
// }
//
// public String getUri() {
// return uri;
// }
//
// public void setUri(String uri) {
// this.uri = uri;
// }
//
// public String getMethodName() {
// return methodName;
// }
//
// public void setMethodName(String methodName) {
// this.methodName = methodName;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
//
// public String getClassNameNormalized() {
// return classNameNormalized;
// }
//
// public void setClassNameNormalized(String classNameNormalized) {
// this.classNameNormalized = classNameNormalized;
// }
//
// public String getSignatureName() {
// return signatureName;
// }
//
// public void setSignatureName(String signatureName) {
// this.signatureName = signatureName;
// }
//
// public TypePath getTypePath() {
// return typePath;
// }
//
// public void setTypePath(TypePath typePath) {
// this.typePath = typePath;
// }
//
// public String getHttpMethod() {
// return httpMethod;
// }
//
// public void setHttpMethod(String httpMethod) {
// this.httpMethod = httpMethod;
// }
//
// public List<EntryPathParam> getListEntryPathData() {
// return listEntryPathData;
// }
//
// public void setListEntryPathData(List<EntryPathParam> listEntryPathData) {
// this.listEntryPathData = listEntryPathData;
// }
//
// @Override
// public String toString() {
// return "EntryPathData [uri=" + uri + ", methodName=" + methodName
// + ", className=" + className + ", classNameNormalized="
// + classNameNormalized + ", signatureName=" + signatureName
// + ", typePath=" + typePath + ", httpMethod=" + httpMethod
// + "]";
// }
// }
//
// Path: h2hell-core/src/main/java/com/highway2urhell/domain/TypePath.java
// public enum TypePath {
// WEBSERVICE, STATIC, DYNAMIC, SERVLET, FILTER, LISTENER, UNKNOWN
// }
//
// Path: h2hell-core/src/main/java/com/highway2urhell/service/AbstractLeechService.java
// public abstract class AbstractLeechService implements LeechService {
//
// private FrameworkInformations frameworkInformations = new FrameworkInformations();
// private boolean triggeredAtStartup = false;
//
// public AbstractLeechService(String frameworkName) {
// frameworkInformations.setFrameworkName(frameworkName);
// }
//
// public AbstractLeechService(String frameworkName, String version) {
// this(frameworkName);
// frameworkInformations.setVersion(version);
// }
//
// @Override
// public boolean isTriggeredAtStartup() {
// return triggeredAtStartup;
// }
//
// protected void setTriggerAtStartup(boolean triggeredAtStartup) {
// this.triggeredAtStartup = triggeredAtStartup;
// }
//
// public void receiveData(List<EntryPathData> incoming) {
// clearPreviousData();
// System.out.println("receive incoming data obj "+ incoming+ "for framework "+frameworkInformations.getFrameworkName());
// gatherData(incoming);
// System.out.println("data gathering complete. Found entries "+frameworkInformations.getListEntryPath().size());
// }
//
// private void clearPreviousData() {
// frameworkInformations.getListEntryPath().clear();
// }
//
//
// protected void gatherData(List<EntryPathData> incoming) {
// List<EntryPathData> listEntryPath = incoming;
// for (EntryPathData entry : listEntryPath) {
// if (entry.getMethodName() != null && !entry.getMethodName().contains("$")) {
// addEntryPath(entry);
// }
// }
// }
//
// @Override
// public FrameworkInformations getFrameworkInformations() {
// return frameworkInformations;
// }
//
// protected void addEntryPath(EntryPathData entryPath) {
// frameworkInformations.getListEntryPath().add(entryPath);
// }
//
// public String getInternalSignature(String className, String methodName) {
// String res = "";
// try {
// Class<?> c = Class.forName(className);
// for (Method m : c.getDeclaredMethods()) {
// if (m.getName().equals(methodName)) {
// res = Type.getMethodDescriptor(m);
// }
// }
//
// } catch (ClassNotFoundException e) {
// System.err.println("Can't construct classname " + className+" : "+ e);
// }
//
// return res;
// }
//
// public String getInternalSignature(Method m) {
// return Type.getMethodDescriptor(m);
// }
// }
// Path: h2hell-core/src/main/java/com/highway2urhell/service/impl/PortService.java
import com.highway2urhell.domain.EntryPathData;
import com.highway2urhell.domain.TypePath;
import com.highway2urhell.service.AbstractLeechService;
import java.io.IOException;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;
package com.highway2urhell.service.impl;
public class PortService extends AbstractLeechService {
public static final String FRAMEWORK_NAME = "SYSTEM-PORT";
private static final int MIN_PORT = 1024;
private static final int MAX_PORT = 65535;
public PortService() {
super(FRAMEWORK_NAME);
setTriggerAtStartup(true);
}
@Override | protected void gatherData(List<EntryPathData> incoming) { |
highway-to-urhell/highway-to-urhell | h2hell-core/src/main/java/com/highway2urhell/service/impl/JmsQueueService.java | // Path: h2hell-core/src/main/java/com/highway2urhell/VersionUtils.java
// public class VersionUtils {
//
// public static final String UNKNOWN_VERSION = "UNKNOWN";
// public static final String NO_FRAMEWORK = "NO_FRAMEWORK";
//
// private VersionUtils() {
// }
//
// public static String getVersion(String clazzName, String groupId, String artifactId) {
// //check
// Class<?> clazz;
// try {
// clazz = Class.forName(clazzName);
// } catch (ClassNotFoundException e1) {
// return NO_FRAMEWORK;
// }
// String version = null;
//
// // try to load from maven properties first
// Properties p = new Properties();
// InputStream is = null;
//
// try {
// is = clazz.getResourceAsStream("/META-INF/maven/" + groupId + "/" + artifactId + "/pom.properties");
// if (is != null) {
// p.load(is);
// version = p.getProperty("version", "");
// }
// } catch (Exception e) {
// // ignore
// } finally {
// if (is != null) {
// try {
// is.close();
// } catch (IOException e) {
// // ignore
// }
// }
// }
//
// // try to load from manifest
// try {
// URL clazzRes = clazz.getResource('/' + clazz.getName().replace('.', '/') + ".class");
// String classResPath = clazzRes.getPath();
// Manifest manifest = null;
// if (classResPath.contains("!")) {
// classResPath = classResPath.split("!")[0];
// URL url = new URL("jar:" + classResPath + "!/");
// JarURLConnection jarConnection = (JarURLConnection) url.openConnection();
// manifest = jarConnection.getManifest();
// } else {
// is = clazz.getResourceAsStream(classResPath + "!/META-INF/MANIFEST.MF");
// if (is != null)
// manifest = new Manifest(is);
//
// }
// if (manifest != null) {
// Attributes attr = manifest.getMainAttributes();
// version = attr.getValue("Implementation-Version");
// }
// } catch (Exception e) {
// // ignore
// } finally {
// if (is != null) {
// try {
// is.close();
// } catch (IOException e) {
// // ignore
// }
// }
// }
//
//
// // fallback to using Java API
// if (version == null) {
// Package aPackage = clazz.getPackage();
// if (aPackage != null) {
// version = aPackage.getImplementationVersion();
// if (version == null) {
// version = aPackage.getSpecificationVersion();
// }
// }
// }
// if (version == null) {
// // we could not compute the version so use a blank
// version = UNKNOWN_VERSION;
// }
//
// return version;
// }
//
// }
//
// Path: h2hell-core/src/main/java/com/highway2urhell/service/AbstractLeechService.java
// public abstract class AbstractLeechService implements LeechService {
//
// private FrameworkInformations frameworkInformations = new FrameworkInformations();
// private boolean triggeredAtStartup = false;
//
// public AbstractLeechService(String frameworkName) {
// frameworkInformations.setFrameworkName(frameworkName);
// }
//
// public AbstractLeechService(String frameworkName, String version) {
// this(frameworkName);
// frameworkInformations.setVersion(version);
// }
//
// @Override
// public boolean isTriggeredAtStartup() {
// return triggeredAtStartup;
// }
//
// protected void setTriggerAtStartup(boolean triggeredAtStartup) {
// this.triggeredAtStartup = triggeredAtStartup;
// }
//
// public void receiveData(List<EntryPathData> incoming) {
// clearPreviousData();
// System.out.println("receive incoming data obj "+ incoming+ "for framework "+frameworkInformations.getFrameworkName());
// gatherData(incoming);
// System.out.println("data gathering complete. Found entries "+frameworkInformations.getListEntryPath().size());
// }
//
// private void clearPreviousData() {
// frameworkInformations.getListEntryPath().clear();
// }
//
//
// protected void gatherData(List<EntryPathData> incoming) {
// List<EntryPathData> listEntryPath = incoming;
// for (EntryPathData entry : listEntryPath) {
// if (entry.getMethodName() != null && !entry.getMethodName().contains("$")) {
// addEntryPath(entry);
// }
// }
// }
//
// @Override
// public FrameworkInformations getFrameworkInformations() {
// return frameworkInformations;
// }
//
// protected void addEntryPath(EntryPathData entryPath) {
// frameworkInformations.getListEntryPath().add(entryPath);
// }
//
// public String getInternalSignature(String className, String methodName) {
// String res = "";
// try {
// Class<?> c = Class.forName(className);
// for (Method m : c.getDeclaredMethods()) {
// if (m.getName().equals(methodName)) {
// res = Type.getMethodDescriptor(m);
// }
// }
//
// } catch (ClassNotFoundException e) {
// System.err.println("Can't construct classname " + className+" : "+ e);
// }
//
// return res;
// }
//
// public String getInternalSignature(Method m) {
// return Type.getMethodDescriptor(m);
// }
// }
| import com.highway2urhell.VersionUtils;
import com.highway2urhell.service.AbstractLeechService; | package com.highway2urhell.service.impl;
public class JmsQueueService extends AbstractLeechService {
public static final String FRAMEWORK_NAME = "JMS_11_CTX";
public JmsQueueService() { | // Path: h2hell-core/src/main/java/com/highway2urhell/VersionUtils.java
// public class VersionUtils {
//
// public static final String UNKNOWN_VERSION = "UNKNOWN";
// public static final String NO_FRAMEWORK = "NO_FRAMEWORK";
//
// private VersionUtils() {
// }
//
// public static String getVersion(String clazzName, String groupId, String artifactId) {
// //check
// Class<?> clazz;
// try {
// clazz = Class.forName(clazzName);
// } catch (ClassNotFoundException e1) {
// return NO_FRAMEWORK;
// }
// String version = null;
//
// // try to load from maven properties first
// Properties p = new Properties();
// InputStream is = null;
//
// try {
// is = clazz.getResourceAsStream("/META-INF/maven/" + groupId + "/" + artifactId + "/pom.properties");
// if (is != null) {
// p.load(is);
// version = p.getProperty("version", "");
// }
// } catch (Exception e) {
// // ignore
// } finally {
// if (is != null) {
// try {
// is.close();
// } catch (IOException e) {
// // ignore
// }
// }
// }
//
// // try to load from manifest
// try {
// URL clazzRes = clazz.getResource('/' + clazz.getName().replace('.', '/') + ".class");
// String classResPath = clazzRes.getPath();
// Manifest manifest = null;
// if (classResPath.contains("!")) {
// classResPath = classResPath.split("!")[0];
// URL url = new URL("jar:" + classResPath + "!/");
// JarURLConnection jarConnection = (JarURLConnection) url.openConnection();
// manifest = jarConnection.getManifest();
// } else {
// is = clazz.getResourceAsStream(classResPath + "!/META-INF/MANIFEST.MF");
// if (is != null)
// manifest = new Manifest(is);
//
// }
// if (manifest != null) {
// Attributes attr = manifest.getMainAttributes();
// version = attr.getValue("Implementation-Version");
// }
// } catch (Exception e) {
// // ignore
// } finally {
// if (is != null) {
// try {
// is.close();
// } catch (IOException e) {
// // ignore
// }
// }
// }
//
//
// // fallback to using Java API
// if (version == null) {
// Package aPackage = clazz.getPackage();
// if (aPackage != null) {
// version = aPackage.getImplementationVersion();
// if (version == null) {
// version = aPackage.getSpecificationVersion();
// }
// }
// }
// if (version == null) {
// // we could not compute the version so use a blank
// version = UNKNOWN_VERSION;
// }
//
// return version;
// }
//
// }
//
// Path: h2hell-core/src/main/java/com/highway2urhell/service/AbstractLeechService.java
// public abstract class AbstractLeechService implements LeechService {
//
// private FrameworkInformations frameworkInformations = new FrameworkInformations();
// private boolean triggeredAtStartup = false;
//
// public AbstractLeechService(String frameworkName) {
// frameworkInformations.setFrameworkName(frameworkName);
// }
//
// public AbstractLeechService(String frameworkName, String version) {
// this(frameworkName);
// frameworkInformations.setVersion(version);
// }
//
// @Override
// public boolean isTriggeredAtStartup() {
// return triggeredAtStartup;
// }
//
// protected void setTriggerAtStartup(boolean triggeredAtStartup) {
// this.triggeredAtStartup = triggeredAtStartup;
// }
//
// public void receiveData(List<EntryPathData> incoming) {
// clearPreviousData();
// System.out.println("receive incoming data obj "+ incoming+ "for framework "+frameworkInformations.getFrameworkName());
// gatherData(incoming);
// System.out.println("data gathering complete. Found entries "+frameworkInformations.getListEntryPath().size());
// }
//
// private void clearPreviousData() {
// frameworkInformations.getListEntryPath().clear();
// }
//
//
// protected void gatherData(List<EntryPathData> incoming) {
// List<EntryPathData> listEntryPath = incoming;
// for (EntryPathData entry : listEntryPath) {
// if (entry.getMethodName() != null && !entry.getMethodName().contains("$")) {
// addEntryPath(entry);
// }
// }
// }
//
// @Override
// public FrameworkInformations getFrameworkInformations() {
// return frameworkInformations;
// }
//
// protected void addEntryPath(EntryPathData entryPath) {
// frameworkInformations.getListEntryPath().add(entryPath);
// }
//
// public String getInternalSignature(String className, String methodName) {
// String res = "";
// try {
// Class<?> c = Class.forName(className);
// for (Method m : c.getDeclaredMethods()) {
// if (m.getName().equals(methodName)) {
// res = Type.getMethodDescriptor(m);
// }
// }
//
// } catch (ClassNotFoundException e) {
// System.err.println("Can't construct classname " + className+" : "+ e);
// }
//
// return res;
// }
//
// public String getInternalSignature(Method m) {
// return Type.getMethodDescriptor(m);
// }
// }
// Path: h2hell-core/src/main/java/com/highway2urhell/service/impl/JmsQueueService.java
import com.highway2urhell.VersionUtils;
import com.highway2urhell.service.AbstractLeechService;
package com.highway2urhell.service.impl;
public class JmsQueueService extends AbstractLeechService {
public static final String FRAMEWORK_NAME = "JMS_11_CTX";
public JmsQueueService() { | super(FRAMEWORK_NAME, VersionUtils.getVersion( |
google/git-appraise-eclipse | ui/src/com/google/appraise/eclipse/ui/editor/AppraiseDiffViewerPart.java | // Path: core/src/com/google/appraise/eclipse/core/AppraiseReviewTaskSchema.java
// public class AppraiseReviewTaskSchema extends AbstractTaskSchema {
// private static final AppraiseReviewTaskSchema instance = new AppraiseReviewTaskSchema();
//
// public static AppraiseReviewTaskSchema getDefault() {
// return instance;
// }
//
// private final DefaultTaskSchema parent = DefaultTaskSchema.getInstance();
//
// public static final String COMMENT_ID_ATTRIBUTE = "appraise.comment.id";
//
// public static final String COMMENT_RESOLVED_ATTRIBUTE = "appraise.comment.resolved";
//
// public static final String COMMENT_PARENT_ATTRIBUTE = "appraise.comment.parent";
//
// public static final String COMMENT_LOCATION_FILE = "appraise.comment.location.file";
//
// public static final String COMMENT_LOCATION_LINE = "appraise.comment.location.line";
//
// public static final String COMMENT_LOCATION_COMMIT = "appraise.comment.location.commit";
//
// public static final String DIFF_TEXT = "appraise.diff.text";
//
// public static final String DIFF_NEWPATH = "appraise.diff.newpath";
//
// public static final String DIFF_OLDPATH = "appraise.diff.oldpath";
//
// public static final String DIFF_TYPE = "appraise.diff.type";
//
// public static final String TYPE_DIFF = "appraise.diff";
//
// /**
// * The prefix for elements of the unified diff for all the commits in the review.
// * Not populated in the partial task data.
// */
// public static final String PREFIX_DIFF = "com.google.appraise.review.Diff-";
//
// public final Field IS_SUBMITTED =
// createField("com.google.appraise.review.IsSubmitted", "Submitted", TaskAttribute.TYPE_BOOLEAN,
// Flag.READ_ONLY);
//
// public final Field REVIEW_REF =
// createField("com.google.appraise.review.ReviewRef", "Review Ref", TaskAttribute.TYPE_SHORT_TEXT);
//
// public final Field TARGET_REF =
// createField("com.google.appraise.review.TargetRef", "Target Ref", TaskAttribute.TYPE_SHORT_TEXT);
//
// public final Field DESCRIPTION = inheritFrom(parent.SUMMARY).create();
//
// public final Field CREATED = inheritFrom(parent.DATE_CREATION).create();
//
// public final Field MODIFIED = inheritFrom(parent.DATE_MODIFICATION).create();
//
// public final Field REQUESTER =
// createField("com.google.appraise.review.Requester", "Requester", TaskAttribute.TYPE_SHORT_TEXT);
//
// public final Field REVIEWERS =
// createField("com.google.appraise.review.Reviewers", "Reviewers", TaskAttribute.TYPE_SHORT_TEXT);
//
// public final Field REVIEW_COMMIT = createField("com.google.appraise.review.ReviewCommit",
// "Review Commit", TaskAttribute.TYPE_SHORT_TEXT, Flag.READ_ONLY);
//
// public final Field KIND = inheritFrom(parent.TASK_KIND).create();
// }
| import com.google.appraise.eclipse.core.AppraiseReviewTaskSchema;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jgit.diff.DiffEntry.ChangeType;
import org.eclipse.mylyn.commons.ui.FillWidthLayout;
import org.eclipse.mylyn.internal.tasks.ui.editors.EditorUtil;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.core.data.TaskData;
import org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor;
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPart;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.IFormColors;
import org.eclipse.ui.forms.events.ExpansionAdapter;
import org.eclipse.ui.forms.events.ExpansionEvent;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;
import java.util.List; | /*******************************************************************************
* Copyright (c) 2015 Google and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Scott McMaster - initial implementation
*******************************************************************************/
package com.google.appraise.eclipse.ui.editor;
/**
* Implements a full-review diff viewer inside a task editor part.
*/
public class AppraiseDiffViewerPart extends AbstractTaskEditorPart {
private static final String KEY_DIFF_ATTRIBUTE_EDITOR = "diffviewer";
/**
* Gets the TYPE_DIFF task attributes off the task data.
*/
private List<TaskAttribute> getDiffTaskAttributes() {
TaskData taskData = getModel().getTaskData();
return taskData.getAttributeMapper().getAttributesByType(taskData, | // Path: core/src/com/google/appraise/eclipse/core/AppraiseReviewTaskSchema.java
// public class AppraiseReviewTaskSchema extends AbstractTaskSchema {
// private static final AppraiseReviewTaskSchema instance = new AppraiseReviewTaskSchema();
//
// public static AppraiseReviewTaskSchema getDefault() {
// return instance;
// }
//
// private final DefaultTaskSchema parent = DefaultTaskSchema.getInstance();
//
// public static final String COMMENT_ID_ATTRIBUTE = "appraise.comment.id";
//
// public static final String COMMENT_RESOLVED_ATTRIBUTE = "appraise.comment.resolved";
//
// public static final String COMMENT_PARENT_ATTRIBUTE = "appraise.comment.parent";
//
// public static final String COMMENT_LOCATION_FILE = "appraise.comment.location.file";
//
// public static final String COMMENT_LOCATION_LINE = "appraise.comment.location.line";
//
// public static final String COMMENT_LOCATION_COMMIT = "appraise.comment.location.commit";
//
// public static final String DIFF_TEXT = "appraise.diff.text";
//
// public static final String DIFF_NEWPATH = "appraise.diff.newpath";
//
// public static final String DIFF_OLDPATH = "appraise.diff.oldpath";
//
// public static final String DIFF_TYPE = "appraise.diff.type";
//
// public static final String TYPE_DIFF = "appraise.diff";
//
// /**
// * The prefix for elements of the unified diff for all the commits in the review.
// * Not populated in the partial task data.
// */
// public static final String PREFIX_DIFF = "com.google.appraise.review.Diff-";
//
// public final Field IS_SUBMITTED =
// createField("com.google.appraise.review.IsSubmitted", "Submitted", TaskAttribute.TYPE_BOOLEAN,
// Flag.READ_ONLY);
//
// public final Field REVIEW_REF =
// createField("com.google.appraise.review.ReviewRef", "Review Ref", TaskAttribute.TYPE_SHORT_TEXT);
//
// public final Field TARGET_REF =
// createField("com.google.appraise.review.TargetRef", "Target Ref", TaskAttribute.TYPE_SHORT_TEXT);
//
// public final Field DESCRIPTION = inheritFrom(parent.SUMMARY).create();
//
// public final Field CREATED = inheritFrom(parent.DATE_CREATION).create();
//
// public final Field MODIFIED = inheritFrom(parent.DATE_MODIFICATION).create();
//
// public final Field REQUESTER =
// createField("com.google.appraise.review.Requester", "Requester", TaskAttribute.TYPE_SHORT_TEXT);
//
// public final Field REVIEWERS =
// createField("com.google.appraise.review.Reviewers", "Reviewers", TaskAttribute.TYPE_SHORT_TEXT);
//
// public final Field REVIEW_COMMIT = createField("com.google.appraise.review.ReviewCommit",
// "Review Commit", TaskAttribute.TYPE_SHORT_TEXT, Flag.READ_ONLY);
//
// public final Field KIND = inheritFrom(parent.TASK_KIND).create();
// }
// Path: ui/src/com/google/appraise/eclipse/ui/editor/AppraiseDiffViewerPart.java
import com.google.appraise.eclipse.core.AppraiseReviewTaskSchema;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jgit.diff.DiffEntry.ChangeType;
import org.eclipse.mylyn.commons.ui.FillWidthLayout;
import org.eclipse.mylyn.internal.tasks.ui.editors.EditorUtil;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.core.data.TaskData;
import org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor;
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPart;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.IFormColors;
import org.eclipse.ui.forms.events.ExpansionAdapter;
import org.eclipse.ui.forms.events.ExpansionEvent;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;
import java.util.List;
/*******************************************************************************
* Copyright (c) 2015 Google and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Scott McMaster - initial implementation
*******************************************************************************/
package com.google.appraise.eclipse.ui.editor;
/**
* Implements a full-review diff viewer inside a task editor part.
*/
public class AppraiseDiffViewerPart extends AbstractTaskEditorPart {
private static final String KEY_DIFF_ATTRIBUTE_EDITOR = "diffviewer";
/**
* Gets the TYPE_DIFF task attributes off the task data.
*/
private List<TaskAttribute> getDiffTaskAttributes() {
TaskData taskData = getModel().getTaskData();
return taskData.getAttributeMapper().getAttributesByType(taskData, | AppraiseReviewTaskSchema.TYPE_DIFF); |
google/git-appraise-eclipse | ui/src/com/google/appraise/eclipse/ui/wizard/AppraiseRepositorySettingsPage.java | // Path: core/src/com/google/appraise/eclipse/core/AppraiseConnectorPlugin.java
// public class AppraiseConnectorPlugin extends Plugin {
// /**
// * The global plugin instance.
// */
// public static AppraiseConnectorPlugin plugin;
//
// /**
// * The plugin id.
// */
// public static final String PLUGIN_ID = "com.google.appraise.eclipse.core";
//
// /**
// * The type of the connector.
// */
// public static final String CONNECTOR_KIND = "com.google.appraise";
//
// /**
// * Connector query attribute for the user as review requestor.
// */
// public static final String QUERY_REQUESTER = PLUGIN_ID + ".requestor";
//
// /**
// * Connector query attribute for the user as reviewer.
// */
// public static final String QUERY_REVIEWER = PLUGIN_ID + ".reviewer";
//
// /**
// * Connector query attribute for the review commit hash prefix.
// */
// public static final String QUERY_REVIEW_COMMIT_PREFIX = PLUGIN_ID + ".reviewcommitprefix";
//
// private static BundleContext context;
//
// static BundleContext getContext() {
// return context;
// }
//
// @Override
// public void start(BundleContext bundleContext) throws Exception {
// super.start(bundleContext);
// plugin = this;
// }
//
// @Override
// public void stop(BundleContext bundleContext) throws Exception {
// plugin = null;
// super.stop(bundleContext);
// }
//
// /**
// * Returns the shared instance.
// */
// public static AppraiseConnectorPlugin getDefault() {
// return plugin;
// }
//
// public static void logError(final String message, final Throwable throwable) {
// getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message, throwable));
// }
//
// public static void logWarning(final String message, final Throwable throwable) {
// getDefault().getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message, throwable));
// }
// }
| import com.google.appraise.eclipse.core.AppraiseConnectorPlugin;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.mylyn.internal.tasks.core.RepositoryTemplateManager;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.tasks.core.RepositoryTemplate;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositorySettingsPage;
import org.eclipse.swt.widgets.Composite;
import java.util.ArrayList;
import java.util.List; | /*******************************************************************************
* Copyright (c) 2015 Google and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Scott McMaster - initial implementation
*******************************************************************************/
package com.google.appraise.eclipse.ui.wizard;
/**
* Custom repository settings page for Appraise.
*/
public class AppraiseRepositorySettingsPage extends AbstractRepositorySettingsPage {
public AppraiseRepositorySettingsPage(TaskRepository repository) {
super("Appraise Repository", "Appraise Repository Connector", repository);
setNeedsAnonymousLogin(false);
setNeedsEncoding(false);
setNeedsTimeZone(false);
setNeedsAdvanced(false);
setNeedsProxy(false);
setNeedsValidation(false);
setNeedsValidateOnFinish(false);
setNeedsAdvanced(false);
setNeedsHttpAuth(false);
}
@Override
public String getConnectorKind() { | // Path: core/src/com/google/appraise/eclipse/core/AppraiseConnectorPlugin.java
// public class AppraiseConnectorPlugin extends Plugin {
// /**
// * The global plugin instance.
// */
// public static AppraiseConnectorPlugin plugin;
//
// /**
// * The plugin id.
// */
// public static final String PLUGIN_ID = "com.google.appraise.eclipse.core";
//
// /**
// * The type of the connector.
// */
// public static final String CONNECTOR_KIND = "com.google.appraise";
//
// /**
// * Connector query attribute for the user as review requestor.
// */
// public static final String QUERY_REQUESTER = PLUGIN_ID + ".requestor";
//
// /**
// * Connector query attribute for the user as reviewer.
// */
// public static final String QUERY_REVIEWER = PLUGIN_ID + ".reviewer";
//
// /**
// * Connector query attribute for the review commit hash prefix.
// */
// public static final String QUERY_REVIEW_COMMIT_PREFIX = PLUGIN_ID + ".reviewcommitprefix";
//
// private static BundleContext context;
//
// static BundleContext getContext() {
// return context;
// }
//
// @Override
// public void start(BundleContext bundleContext) throws Exception {
// super.start(bundleContext);
// plugin = this;
// }
//
// @Override
// public void stop(BundleContext bundleContext) throws Exception {
// plugin = null;
// super.stop(bundleContext);
// }
//
// /**
// * Returns the shared instance.
// */
// public static AppraiseConnectorPlugin getDefault() {
// return plugin;
// }
//
// public static void logError(final String message, final Throwable throwable) {
// getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message, throwable));
// }
//
// public static void logWarning(final String message, final Throwable throwable) {
// getDefault().getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message, throwable));
// }
// }
// Path: ui/src/com/google/appraise/eclipse/ui/wizard/AppraiseRepositorySettingsPage.java
import com.google.appraise.eclipse.core.AppraiseConnectorPlugin;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.mylyn.internal.tasks.core.RepositoryTemplateManager;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.tasks.core.RepositoryTemplate;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositorySettingsPage;
import org.eclipse.swt.widgets.Composite;
import java.util.ArrayList;
import java.util.List;
/*******************************************************************************
* Copyright (c) 2015 Google and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Scott McMaster - initial implementation
*******************************************************************************/
package com.google.appraise.eclipse.ui.wizard;
/**
* Custom repository settings page for Appraise.
*/
public class AppraiseRepositorySettingsPage extends AbstractRepositorySettingsPage {
public AppraiseRepositorySettingsPage(TaskRepository repository) {
super("Appraise Repository", "Appraise Repository Connector", repository);
setNeedsAnonymousLogin(false);
setNeedsEncoding(false);
setNeedsTimeZone(false);
setNeedsAdvanced(false);
setNeedsProxy(false);
setNeedsValidation(false);
setNeedsValidateOnFinish(false);
setNeedsAdvanced(false);
setNeedsHttpAuth(false);
}
@Override
public String getConnectorKind() { | return AppraiseConnectorPlugin.CONNECTOR_KIND; |
google/git-appraise-eclipse | ui/src/com/google/appraise/eclipse/ui/editor/AppraiseReviewTaskEditorPageFactory.java | // Path: core/src/com/google/appraise/eclipse/core/AppraiseConnectorPlugin.java
// public class AppraiseConnectorPlugin extends Plugin {
// /**
// * The global plugin instance.
// */
// public static AppraiseConnectorPlugin plugin;
//
// /**
// * The plugin id.
// */
// public static final String PLUGIN_ID = "com.google.appraise.eclipse.core";
//
// /**
// * The type of the connector.
// */
// public static final String CONNECTOR_KIND = "com.google.appraise";
//
// /**
// * Connector query attribute for the user as review requestor.
// */
// public static final String QUERY_REQUESTER = PLUGIN_ID + ".requestor";
//
// /**
// * Connector query attribute for the user as reviewer.
// */
// public static final String QUERY_REVIEWER = PLUGIN_ID + ".reviewer";
//
// /**
// * Connector query attribute for the review commit hash prefix.
// */
// public static final String QUERY_REVIEW_COMMIT_PREFIX = PLUGIN_ID + ".reviewcommitprefix";
//
// private static BundleContext context;
//
// static BundleContext getContext() {
// return context;
// }
//
// @Override
// public void start(BundleContext bundleContext) throws Exception {
// super.start(bundleContext);
// plugin = this;
// }
//
// @Override
// public void stop(BundleContext bundleContext) throws Exception {
// plugin = null;
// super.stop(bundleContext);
// }
//
// /**
// * Returns the shared instance.
// */
// public static AppraiseConnectorPlugin getDefault() {
// return plugin;
// }
//
// public static void logError(final String message, final Throwable throwable) {
// getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message, throwable));
// }
//
// public static void logWarning(final String message, final Throwable throwable) {
// getDefault().getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message, throwable));
// }
// }
| import com.google.appraise.eclipse.core.AppraiseConnectorPlugin;
import org.eclipse.mylyn.commons.ui.CommonImages;
import org.eclipse.mylyn.tasks.ui.TasksUiImages;
import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPageFactory;
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
import org.eclipse.mylyn.tasks.ui.editors.TaskEditorInput;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.forms.editor.IFormPage; | /*******************************************************************************
* Copyright (c) 2015 Google and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Scott McMaster - initial implementation
*******************************************************************************/
package com.google.appraise.eclipse.ui.editor;
/**
* Creates the main review viewing/editing page.
*/
public class AppraiseReviewTaskEditorPageFactory extends AbstractTaskEditorPageFactory {
@Override
public boolean canCreatePageFor(TaskEditorInput input) { | // Path: core/src/com/google/appraise/eclipse/core/AppraiseConnectorPlugin.java
// public class AppraiseConnectorPlugin extends Plugin {
// /**
// * The global plugin instance.
// */
// public static AppraiseConnectorPlugin plugin;
//
// /**
// * The plugin id.
// */
// public static final String PLUGIN_ID = "com.google.appraise.eclipse.core";
//
// /**
// * The type of the connector.
// */
// public static final String CONNECTOR_KIND = "com.google.appraise";
//
// /**
// * Connector query attribute for the user as review requestor.
// */
// public static final String QUERY_REQUESTER = PLUGIN_ID + ".requestor";
//
// /**
// * Connector query attribute for the user as reviewer.
// */
// public static final String QUERY_REVIEWER = PLUGIN_ID + ".reviewer";
//
// /**
// * Connector query attribute for the review commit hash prefix.
// */
// public static final String QUERY_REVIEW_COMMIT_PREFIX = PLUGIN_ID + ".reviewcommitprefix";
//
// private static BundleContext context;
//
// static BundleContext getContext() {
// return context;
// }
//
// @Override
// public void start(BundleContext bundleContext) throws Exception {
// super.start(bundleContext);
// plugin = this;
// }
//
// @Override
// public void stop(BundleContext bundleContext) throws Exception {
// plugin = null;
// super.stop(bundleContext);
// }
//
// /**
// * Returns the shared instance.
// */
// public static AppraiseConnectorPlugin getDefault() {
// return plugin;
// }
//
// public static void logError(final String message, final Throwable throwable) {
// getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message, throwable));
// }
//
// public static void logWarning(final String message, final Throwable throwable) {
// getDefault().getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message, throwable));
// }
// }
// Path: ui/src/com/google/appraise/eclipse/ui/editor/AppraiseReviewTaskEditorPageFactory.java
import com.google.appraise.eclipse.core.AppraiseConnectorPlugin;
import org.eclipse.mylyn.commons.ui.CommonImages;
import org.eclipse.mylyn.tasks.ui.TasksUiImages;
import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPageFactory;
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
import org.eclipse.mylyn.tasks.ui.editors.TaskEditorInput;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.forms.editor.IFormPage;
/*******************************************************************************
* Copyright (c) 2015 Google and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Scott McMaster - initial implementation
*******************************************************************************/
package com.google.appraise.eclipse.ui.editor;
/**
* Creates the main review viewing/editing page.
*/
public class AppraiseReviewTaskEditorPageFactory extends AbstractTaskEditorPageFactory {
@Override
public boolean canCreatePageFor(TaskEditorInput input) { | return (input.getTask().getConnectorKind().equals(AppraiseConnectorPlugin.CONNECTOR_KIND) |
google/git-appraise-eclipse | ui/src/com/google/appraise/eclipse/ui/AppraiseConnectorUi.java | // Path: core/src/com/google/appraise/eclipse/core/AppraiseConnectorPlugin.java
// public class AppraiseConnectorPlugin extends Plugin {
// /**
// * The global plugin instance.
// */
// public static AppraiseConnectorPlugin plugin;
//
// /**
// * The plugin id.
// */
// public static final String PLUGIN_ID = "com.google.appraise.eclipse.core";
//
// /**
// * The type of the connector.
// */
// public static final String CONNECTOR_KIND = "com.google.appraise";
//
// /**
// * Connector query attribute for the user as review requestor.
// */
// public static final String QUERY_REQUESTER = PLUGIN_ID + ".requestor";
//
// /**
// * Connector query attribute for the user as reviewer.
// */
// public static final String QUERY_REVIEWER = PLUGIN_ID + ".reviewer";
//
// /**
// * Connector query attribute for the review commit hash prefix.
// */
// public static final String QUERY_REVIEW_COMMIT_PREFIX = PLUGIN_ID + ".reviewcommitprefix";
//
// private static BundleContext context;
//
// static BundleContext getContext() {
// return context;
// }
//
// @Override
// public void start(BundleContext bundleContext) throws Exception {
// super.start(bundleContext);
// plugin = this;
// }
//
// @Override
// public void stop(BundleContext bundleContext) throws Exception {
// plugin = null;
// super.stop(bundleContext);
// }
//
// /**
// * Returns the shared instance.
// */
// public static AppraiseConnectorPlugin getDefault() {
// return plugin;
// }
//
// public static void logError(final String message, final Throwable throwable) {
// getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message, throwable));
// }
//
// public static void logWarning(final String message, final Throwable throwable) {
// getDefault().getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message, throwable));
// }
// }
//
// Path: ui/src/com/google/appraise/eclipse/ui/wizard/AppraiseRepositorySettingsPage.java
// public class AppraiseRepositorySettingsPage extends AbstractRepositorySettingsPage {
// public AppraiseRepositorySettingsPage(TaskRepository repository) {
// super("Appraise Repository", "Appraise Repository Connector", repository);
// setNeedsAnonymousLogin(false);
// setNeedsEncoding(false);
// setNeedsTimeZone(false);
// setNeedsAdvanced(false);
// setNeedsProxy(false);
// setNeedsValidation(false);
// setNeedsValidateOnFinish(false);
// setNeedsAdvanced(false);
// setNeedsHttpAuth(false);
// }
//
// @Override
// public String getConnectorKind() {
// return AppraiseConnectorPlugin.CONNECTOR_KIND;
// }
//
// private List<IProject> getProjects() {
// List<IProject> projects = new ArrayList<IProject>();
// for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
// projects.add(project);
// }
// return projects;
// }
//
// @Override
// protected void repositoryTemplateSelected(RepositoryTemplate template) {
// repositoryLabelEditor.setStringValue(template.label);
// setUrl(template.repositoryUrl);
// setUserId(System.getProperty("user.name"));
// setPassword("");
//
// getContainer().updateButtons();
// }
//
// @Override
// protected void addRepositoryTemplatesToServerUrlCombo() {
// RepositoryTemplateManager templateManager = TasksUiPlugin.getRepositoryTemplateManager();
//
// for (IProject project : getProjects()) {
// String label = "Appraise: " + project.getName();
// String repositoryUrl = "http://appraise.google.com/" + project.getName();
//
// boolean found = false;
// for (RepositoryTemplate existing :
// templateManager.getTemplates(AppraiseConnectorPlugin.CONNECTOR_KIND)) {
// if (repositoryUrl.equals(existing.repositoryUrl)) {
// found = true;
// break;
// }
// }
//
// if (!found) {
// RepositoryTemplate template = new RepositoryTemplate(
// label, repositoryUrl, null, null, null, null, null, null, true, false);
// TasksUiPlugin.getRepositoryTemplateManager().addTemplate(
// AppraiseConnectorPlugin.CONNECTOR_KIND, template);
// }
// }
// super.addRepositoryTemplatesToServerUrlCombo();
// }
//
// @Override
// protected void createAdditionalControls(Composite parent) {}
//
// @Override
// public void createControl(Composite parent) {
// super.createControl(parent);
// addRepositoryTemplatesToServerUrlCombo();
// }
//
// @Override
// protected boolean isValidUrl(String url) {
// return url != null && url.trim().length() > 0;
// }
//
// @Override
// protected Validator getValidator(TaskRepository repository) {
// return null;
// }
// }
| import com.google.appraise.eclipse.core.AppraiseConnectorPlugin;
import com.google.appraise.eclipse.ui.wizard.AppraiseRepositorySettingsPage;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.ITaskMapping;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi;
import org.eclipse.mylyn.tasks.ui.wizards.ITaskRepositoryPage;
import org.eclipse.mylyn.tasks.ui.wizards.NewTaskWizard;
import org.eclipse.mylyn.tasks.ui.wizards.RepositoryQueryWizard; | /*******************************************************************************
* Copyright (c) 2015 Google and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Scott McMaster - initial implementation
*******************************************************************************/
package com.google.appraise.eclipse.ui;
/**
* The UI extensions for the Appraise plugin.
*/
public class AppraiseConnectorUi extends AbstractRepositoryConnectorUi {
@Override
public String getConnectorKind() { | // Path: core/src/com/google/appraise/eclipse/core/AppraiseConnectorPlugin.java
// public class AppraiseConnectorPlugin extends Plugin {
// /**
// * The global plugin instance.
// */
// public static AppraiseConnectorPlugin plugin;
//
// /**
// * The plugin id.
// */
// public static final String PLUGIN_ID = "com.google.appraise.eclipse.core";
//
// /**
// * The type of the connector.
// */
// public static final String CONNECTOR_KIND = "com.google.appraise";
//
// /**
// * Connector query attribute for the user as review requestor.
// */
// public static final String QUERY_REQUESTER = PLUGIN_ID + ".requestor";
//
// /**
// * Connector query attribute for the user as reviewer.
// */
// public static final String QUERY_REVIEWER = PLUGIN_ID + ".reviewer";
//
// /**
// * Connector query attribute for the review commit hash prefix.
// */
// public static final String QUERY_REVIEW_COMMIT_PREFIX = PLUGIN_ID + ".reviewcommitprefix";
//
// private static BundleContext context;
//
// static BundleContext getContext() {
// return context;
// }
//
// @Override
// public void start(BundleContext bundleContext) throws Exception {
// super.start(bundleContext);
// plugin = this;
// }
//
// @Override
// public void stop(BundleContext bundleContext) throws Exception {
// plugin = null;
// super.stop(bundleContext);
// }
//
// /**
// * Returns the shared instance.
// */
// public static AppraiseConnectorPlugin getDefault() {
// return plugin;
// }
//
// public static void logError(final String message, final Throwable throwable) {
// getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message, throwable));
// }
//
// public static void logWarning(final String message, final Throwable throwable) {
// getDefault().getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message, throwable));
// }
// }
//
// Path: ui/src/com/google/appraise/eclipse/ui/wizard/AppraiseRepositorySettingsPage.java
// public class AppraiseRepositorySettingsPage extends AbstractRepositorySettingsPage {
// public AppraiseRepositorySettingsPage(TaskRepository repository) {
// super("Appraise Repository", "Appraise Repository Connector", repository);
// setNeedsAnonymousLogin(false);
// setNeedsEncoding(false);
// setNeedsTimeZone(false);
// setNeedsAdvanced(false);
// setNeedsProxy(false);
// setNeedsValidation(false);
// setNeedsValidateOnFinish(false);
// setNeedsAdvanced(false);
// setNeedsHttpAuth(false);
// }
//
// @Override
// public String getConnectorKind() {
// return AppraiseConnectorPlugin.CONNECTOR_KIND;
// }
//
// private List<IProject> getProjects() {
// List<IProject> projects = new ArrayList<IProject>();
// for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
// projects.add(project);
// }
// return projects;
// }
//
// @Override
// protected void repositoryTemplateSelected(RepositoryTemplate template) {
// repositoryLabelEditor.setStringValue(template.label);
// setUrl(template.repositoryUrl);
// setUserId(System.getProperty("user.name"));
// setPassword("");
//
// getContainer().updateButtons();
// }
//
// @Override
// protected void addRepositoryTemplatesToServerUrlCombo() {
// RepositoryTemplateManager templateManager = TasksUiPlugin.getRepositoryTemplateManager();
//
// for (IProject project : getProjects()) {
// String label = "Appraise: " + project.getName();
// String repositoryUrl = "http://appraise.google.com/" + project.getName();
//
// boolean found = false;
// for (RepositoryTemplate existing :
// templateManager.getTemplates(AppraiseConnectorPlugin.CONNECTOR_KIND)) {
// if (repositoryUrl.equals(existing.repositoryUrl)) {
// found = true;
// break;
// }
// }
//
// if (!found) {
// RepositoryTemplate template = new RepositoryTemplate(
// label, repositoryUrl, null, null, null, null, null, null, true, false);
// TasksUiPlugin.getRepositoryTemplateManager().addTemplate(
// AppraiseConnectorPlugin.CONNECTOR_KIND, template);
// }
// }
// super.addRepositoryTemplatesToServerUrlCombo();
// }
//
// @Override
// protected void createAdditionalControls(Composite parent) {}
//
// @Override
// public void createControl(Composite parent) {
// super.createControl(parent);
// addRepositoryTemplatesToServerUrlCombo();
// }
//
// @Override
// protected boolean isValidUrl(String url) {
// return url != null && url.trim().length() > 0;
// }
//
// @Override
// protected Validator getValidator(TaskRepository repository) {
// return null;
// }
// }
// Path: ui/src/com/google/appraise/eclipse/ui/AppraiseConnectorUi.java
import com.google.appraise.eclipse.core.AppraiseConnectorPlugin;
import com.google.appraise.eclipse.ui.wizard.AppraiseRepositorySettingsPage;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.ITaskMapping;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi;
import org.eclipse.mylyn.tasks.ui.wizards.ITaskRepositoryPage;
import org.eclipse.mylyn.tasks.ui.wizards.NewTaskWizard;
import org.eclipse.mylyn.tasks.ui.wizards.RepositoryQueryWizard;
/*******************************************************************************
* Copyright (c) 2015 Google and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Scott McMaster - initial implementation
*******************************************************************************/
package com.google.appraise.eclipse.ui;
/**
* The UI extensions for the Appraise plugin.
*/
public class AppraiseConnectorUi extends AbstractRepositoryConnectorUi {
@Override
public String getConnectorKind() { | return AppraiseConnectorPlugin.CONNECTOR_KIND; |
google/git-appraise-eclipse | ui/src/com/google/appraise/eclipse/ui/AppraiseConnectorUi.java | // Path: core/src/com/google/appraise/eclipse/core/AppraiseConnectorPlugin.java
// public class AppraiseConnectorPlugin extends Plugin {
// /**
// * The global plugin instance.
// */
// public static AppraiseConnectorPlugin plugin;
//
// /**
// * The plugin id.
// */
// public static final String PLUGIN_ID = "com.google.appraise.eclipse.core";
//
// /**
// * The type of the connector.
// */
// public static final String CONNECTOR_KIND = "com.google.appraise";
//
// /**
// * Connector query attribute for the user as review requestor.
// */
// public static final String QUERY_REQUESTER = PLUGIN_ID + ".requestor";
//
// /**
// * Connector query attribute for the user as reviewer.
// */
// public static final String QUERY_REVIEWER = PLUGIN_ID + ".reviewer";
//
// /**
// * Connector query attribute for the review commit hash prefix.
// */
// public static final String QUERY_REVIEW_COMMIT_PREFIX = PLUGIN_ID + ".reviewcommitprefix";
//
// private static BundleContext context;
//
// static BundleContext getContext() {
// return context;
// }
//
// @Override
// public void start(BundleContext bundleContext) throws Exception {
// super.start(bundleContext);
// plugin = this;
// }
//
// @Override
// public void stop(BundleContext bundleContext) throws Exception {
// plugin = null;
// super.stop(bundleContext);
// }
//
// /**
// * Returns the shared instance.
// */
// public static AppraiseConnectorPlugin getDefault() {
// return plugin;
// }
//
// public static void logError(final String message, final Throwable throwable) {
// getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message, throwable));
// }
//
// public static void logWarning(final String message, final Throwable throwable) {
// getDefault().getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message, throwable));
// }
// }
//
// Path: ui/src/com/google/appraise/eclipse/ui/wizard/AppraiseRepositorySettingsPage.java
// public class AppraiseRepositorySettingsPage extends AbstractRepositorySettingsPage {
// public AppraiseRepositorySettingsPage(TaskRepository repository) {
// super("Appraise Repository", "Appraise Repository Connector", repository);
// setNeedsAnonymousLogin(false);
// setNeedsEncoding(false);
// setNeedsTimeZone(false);
// setNeedsAdvanced(false);
// setNeedsProxy(false);
// setNeedsValidation(false);
// setNeedsValidateOnFinish(false);
// setNeedsAdvanced(false);
// setNeedsHttpAuth(false);
// }
//
// @Override
// public String getConnectorKind() {
// return AppraiseConnectorPlugin.CONNECTOR_KIND;
// }
//
// private List<IProject> getProjects() {
// List<IProject> projects = new ArrayList<IProject>();
// for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
// projects.add(project);
// }
// return projects;
// }
//
// @Override
// protected void repositoryTemplateSelected(RepositoryTemplate template) {
// repositoryLabelEditor.setStringValue(template.label);
// setUrl(template.repositoryUrl);
// setUserId(System.getProperty("user.name"));
// setPassword("");
//
// getContainer().updateButtons();
// }
//
// @Override
// protected void addRepositoryTemplatesToServerUrlCombo() {
// RepositoryTemplateManager templateManager = TasksUiPlugin.getRepositoryTemplateManager();
//
// for (IProject project : getProjects()) {
// String label = "Appraise: " + project.getName();
// String repositoryUrl = "http://appraise.google.com/" + project.getName();
//
// boolean found = false;
// for (RepositoryTemplate existing :
// templateManager.getTemplates(AppraiseConnectorPlugin.CONNECTOR_KIND)) {
// if (repositoryUrl.equals(existing.repositoryUrl)) {
// found = true;
// break;
// }
// }
//
// if (!found) {
// RepositoryTemplate template = new RepositoryTemplate(
// label, repositoryUrl, null, null, null, null, null, null, true, false);
// TasksUiPlugin.getRepositoryTemplateManager().addTemplate(
// AppraiseConnectorPlugin.CONNECTOR_KIND, template);
// }
// }
// super.addRepositoryTemplatesToServerUrlCombo();
// }
//
// @Override
// protected void createAdditionalControls(Composite parent) {}
//
// @Override
// public void createControl(Composite parent) {
// super.createControl(parent);
// addRepositoryTemplatesToServerUrlCombo();
// }
//
// @Override
// protected boolean isValidUrl(String url) {
// return url != null && url.trim().length() > 0;
// }
//
// @Override
// protected Validator getValidator(TaskRepository repository) {
// return null;
// }
// }
| import com.google.appraise.eclipse.core.AppraiseConnectorPlugin;
import com.google.appraise.eclipse.ui.wizard.AppraiseRepositorySettingsPage;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.ITaskMapping;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi;
import org.eclipse.mylyn.tasks.ui.wizards.ITaskRepositoryPage;
import org.eclipse.mylyn.tasks.ui.wizards.NewTaskWizard;
import org.eclipse.mylyn.tasks.ui.wizards.RepositoryQueryWizard; | /*******************************************************************************
* Copyright (c) 2015 Google and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Scott McMaster - initial implementation
*******************************************************************************/
package com.google.appraise.eclipse.ui;
/**
* The UI extensions for the Appraise plugin.
*/
public class AppraiseConnectorUi extends AbstractRepositoryConnectorUi {
@Override
public String getConnectorKind() {
return AppraiseConnectorPlugin.CONNECTOR_KIND;
}
@Override
public ITaskRepositoryPage getSettingsPage(TaskRepository repository) { | // Path: core/src/com/google/appraise/eclipse/core/AppraiseConnectorPlugin.java
// public class AppraiseConnectorPlugin extends Plugin {
// /**
// * The global plugin instance.
// */
// public static AppraiseConnectorPlugin plugin;
//
// /**
// * The plugin id.
// */
// public static final String PLUGIN_ID = "com.google.appraise.eclipse.core";
//
// /**
// * The type of the connector.
// */
// public static final String CONNECTOR_KIND = "com.google.appraise";
//
// /**
// * Connector query attribute for the user as review requestor.
// */
// public static final String QUERY_REQUESTER = PLUGIN_ID + ".requestor";
//
// /**
// * Connector query attribute for the user as reviewer.
// */
// public static final String QUERY_REVIEWER = PLUGIN_ID + ".reviewer";
//
// /**
// * Connector query attribute for the review commit hash prefix.
// */
// public static final String QUERY_REVIEW_COMMIT_PREFIX = PLUGIN_ID + ".reviewcommitprefix";
//
// private static BundleContext context;
//
// static BundleContext getContext() {
// return context;
// }
//
// @Override
// public void start(BundleContext bundleContext) throws Exception {
// super.start(bundleContext);
// plugin = this;
// }
//
// @Override
// public void stop(BundleContext bundleContext) throws Exception {
// plugin = null;
// super.stop(bundleContext);
// }
//
// /**
// * Returns the shared instance.
// */
// public static AppraiseConnectorPlugin getDefault() {
// return plugin;
// }
//
// public static void logError(final String message, final Throwable throwable) {
// getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message, throwable));
// }
//
// public static void logWarning(final String message, final Throwable throwable) {
// getDefault().getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message, throwable));
// }
// }
//
// Path: ui/src/com/google/appraise/eclipse/ui/wizard/AppraiseRepositorySettingsPage.java
// public class AppraiseRepositorySettingsPage extends AbstractRepositorySettingsPage {
// public AppraiseRepositorySettingsPage(TaskRepository repository) {
// super("Appraise Repository", "Appraise Repository Connector", repository);
// setNeedsAnonymousLogin(false);
// setNeedsEncoding(false);
// setNeedsTimeZone(false);
// setNeedsAdvanced(false);
// setNeedsProxy(false);
// setNeedsValidation(false);
// setNeedsValidateOnFinish(false);
// setNeedsAdvanced(false);
// setNeedsHttpAuth(false);
// }
//
// @Override
// public String getConnectorKind() {
// return AppraiseConnectorPlugin.CONNECTOR_KIND;
// }
//
// private List<IProject> getProjects() {
// List<IProject> projects = new ArrayList<IProject>();
// for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
// projects.add(project);
// }
// return projects;
// }
//
// @Override
// protected void repositoryTemplateSelected(RepositoryTemplate template) {
// repositoryLabelEditor.setStringValue(template.label);
// setUrl(template.repositoryUrl);
// setUserId(System.getProperty("user.name"));
// setPassword("");
//
// getContainer().updateButtons();
// }
//
// @Override
// protected void addRepositoryTemplatesToServerUrlCombo() {
// RepositoryTemplateManager templateManager = TasksUiPlugin.getRepositoryTemplateManager();
//
// for (IProject project : getProjects()) {
// String label = "Appraise: " + project.getName();
// String repositoryUrl = "http://appraise.google.com/" + project.getName();
//
// boolean found = false;
// for (RepositoryTemplate existing :
// templateManager.getTemplates(AppraiseConnectorPlugin.CONNECTOR_KIND)) {
// if (repositoryUrl.equals(existing.repositoryUrl)) {
// found = true;
// break;
// }
// }
//
// if (!found) {
// RepositoryTemplate template = new RepositoryTemplate(
// label, repositoryUrl, null, null, null, null, null, null, true, false);
// TasksUiPlugin.getRepositoryTemplateManager().addTemplate(
// AppraiseConnectorPlugin.CONNECTOR_KIND, template);
// }
// }
// super.addRepositoryTemplatesToServerUrlCombo();
// }
//
// @Override
// protected void createAdditionalControls(Composite parent) {}
//
// @Override
// public void createControl(Composite parent) {
// super.createControl(parent);
// addRepositoryTemplatesToServerUrlCombo();
// }
//
// @Override
// protected boolean isValidUrl(String url) {
// return url != null && url.trim().length() > 0;
// }
//
// @Override
// protected Validator getValidator(TaskRepository repository) {
// return null;
// }
// }
// Path: ui/src/com/google/appraise/eclipse/ui/AppraiseConnectorUi.java
import com.google.appraise.eclipse.core.AppraiseConnectorPlugin;
import com.google.appraise.eclipse.ui.wizard.AppraiseRepositorySettingsPage;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.ITaskMapping;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi;
import org.eclipse.mylyn.tasks.ui.wizards.ITaskRepositoryPage;
import org.eclipse.mylyn.tasks.ui.wizards.NewTaskWizard;
import org.eclipse.mylyn.tasks.ui.wizards.RepositoryQueryWizard;
/*******************************************************************************
* Copyright (c) 2015 Google and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Scott McMaster - initial implementation
*******************************************************************************/
package com.google.appraise.eclipse.ui;
/**
* The UI extensions for the Appraise plugin.
*/
public class AppraiseConnectorUi extends AbstractRepositoryConnectorUi {
@Override
public String getConnectorKind() {
return AppraiseConnectorPlugin.CONNECTOR_KIND;
}
@Override
public ITaskRepositoryPage getSettingsPage(TaskRepository repository) { | return new AppraiseRepositorySettingsPage(repository); |
google/git-appraise-eclipse | ui/src/com/google/appraise/eclipse/ui/AppraiseReviewsQueryPage.java | // Path: core/src/com/google/appraise/eclipse/core/AppraiseConnectorPlugin.java
// public class AppraiseConnectorPlugin extends Plugin {
// /**
// * The global plugin instance.
// */
// public static AppraiseConnectorPlugin plugin;
//
// /**
// * The plugin id.
// */
// public static final String PLUGIN_ID = "com.google.appraise.eclipse.core";
//
// /**
// * The type of the connector.
// */
// public static final String CONNECTOR_KIND = "com.google.appraise";
//
// /**
// * Connector query attribute for the user as review requestor.
// */
// public static final String QUERY_REQUESTER = PLUGIN_ID + ".requestor";
//
// /**
// * Connector query attribute for the user as reviewer.
// */
// public static final String QUERY_REVIEWER = PLUGIN_ID + ".reviewer";
//
// /**
// * Connector query attribute for the review commit hash prefix.
// */
// public static final String QUERY_REVIEW_COMMIT_PREFIX = PLUGIN_ID + ".reviewcommitprefix";
//
// private static BundleContext context;
//
// static BundleContext getContext() {
// return context;
// }
//
// @Override
// public void start(BundleContext bundleContext) throws Exception {
// super.start(bundleContext);
// plugin = this;
// }
//
// @Override
// public void stop(BundleContext bundleContext) throws Exception {
// plugin = null;
// super.stop(bundleContext);
// }
//
// /**
// * Returns the shared instance.
// */
// public static AppraiseConnectorPlugin getDefault() {
// return plugin;
// }
//
// public static void logError(final String message, final Throwable throwable) {
// getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message, throwable));
// }
//
// public static void logWarning(final String message, final Throwable throwable) {
// getDefault().getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message, throwable));
// }
// }
| import com.google.appraise.eclipse.core.AppraiseConnectorPlugin;
import org.eclipse.mylyn.commons.workbench.forms.SectionComposite;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositoryQueryPage2;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text; | /*******************************************************************************
* Copyright (c) 2015 Google and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Scott McMaster - initial implementation
*******************************************************************************/
package com.google.appraise.eclipse.ui;
/**
* Custom Appraise review query page.
*/
public class AppraiseReviewsQueryPage extends AbstractRepositoryQueryPage2 {
private Button requesterCheckbox;
private Button reviewerCheckbox;
private Text reviewCommitPrefixText;
public AppraiseReviewsQueryPage(TaskRepository repository, IRepositoryQuery query) {
super("reviews", repository, query);
setTitle("Appraise Review Search");
setDescription("Specify search parameters.");
}
@Override
protected void createPageContent(SectionComposite parent) {
Composite composite = parent.getContent();
composite.setLayout(new GridLayout(2, false));
requesterCheckbox = new Button(composite, SWT.CHECK);
requesterCheckbox.setText("Requester");
reviewerCheckbox = new Button(composite, SWT.CHECK);
reviewerCheckbox.setText("Reviewer");
Label reviewCommitPrefixLabel = new Label(composite, SWT.NONE);
reviewCommitPrefixLabel.setText("Review Commit Hash (prefix):");
reviewCommitPrefixText = new Text(composite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
composite.pack();
}
@Override
protected boolean hasRepositoryConfiguration() {
return true;
}
@Override
protected boolean restoreState(IRepositoryQuery query) { | // Path: core/src/com/google/appraise/eclipse/core/AppraiseConnectorPlugin.java
// public class AppraiseConnectorPlugin extends Plugin {
// /**
// * The global plugin instance.
// */
// public static AppraiseConnectorPlugin plugin;
//
// /**
// * The plugin id.
// */
// public static final String PLUGIN_ID = "com.google.appraise.eclipse.core";
//
// /**
// * The type of the connector.
// */
// public static final String CONNECTOR_KIND = "com.google.appraise";
//
// /**
// * Connector query attribute for the user as review requestor.
// */
// public static final String QUERY_REQUESTER = PLUGIN_ID + ".requestor";
//
// /**
// * Connector query attribute for the user as reviewer.
// */
// public static final String QUERY_REVIEWER = PLUGIN_ID + ".reviewer";
//
// /**
// * Connector query attribute for the review commit hash prefix.
// */
// public static final String QUERY_REVIEW_COMMIT_PREFIX = PLUGIN_ID + ".reviewcommitprefix";
//
// private static BundleContext context;
//
// static BundleContext getContext() {
// return context;
// }
//
// @Override
// public void start(BundleContext bundleContext) throws Exception {
// super.start(bundleContext);
// plugin = this;
// }
//
// @Override
// public void stop(BundleContext bundleContext) throws Exception {
// plugin = null;
// super.stop(bundleContext);
// }
//
// /**
// * Returns the shared instance.
// */
// public static AppraiseConnectorPlugin getDefault() {
// return plugin;
// }
//
// public static void logError(final String message, final Throwable throwable) {
// getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message, throwable));
// }
//
// public static void logWarning(final String message, final Throwable throwable) {
// getDefault().getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message, throwable));
// }
// }
// Path: ui/src/com/google/appraise/eclipse/ui/AppraiseReviewsQueryPage.java
import com.google.appraise.eclipse.core.AppraiseConnectorPlugin;
import org.eclipse.mylyn.commons.workbench.forms.SectionComposite;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositoryQueryPage2;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
/*******************************************************************************
* Copyright (c) 2015 Google and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Scott McMaster - initial implementation
*******************************************************************************/
package com.google.appraise.eclipse.ui;
/**
* Custom Appraise review query page.
*/
public class AppraiseReviewsQueryPage extends AbstractRepositoryQueryPage2 {
private Button requesterCheckbox;
private Button reviewerCheckbox;
private Text reviewCommitPrefixText;
public AppraiseReviewsQueryPage(TaskRepository repository, IRepositoryQuery query) {
super("reviews", repository, query);
setTitle("Appraise Review Search");
setDescription("Specify search parameters.");
}
@Override
protected void createPageContent(SectionComposite parent) {
Composite composite = parent.getContent();
composite.setLayout(new GridLayout(2, false));
requesterCheckbox = new Button(composite, SWT.CHECK);
requesterCheckbox.setText("Requester");
reviewerCheckbox = new Button(composite, SWT.CHECK);
reviewerCheckbox.setText("Reviewer");
Label reviewCommitPrefixLabel = new Label(composite, SWT.NONE);
reviewCommitPrefixLabel.setText("Review Commit Hash (prefix):");
reviewCommitPrefixText = new Text(composite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
composite.pack();
}
@Override
protected boolean hasRepositoryConfiguration() {
return true;
}
@Override
protected boolean restoreState(IRepositoryQuery query) { | String requester = query.getAttribute(AppraiseConnectorPlugin.QUERY_REQUESTER); |
IMAGINARY/jsurf | src/main/java/de/mfo/jsurf/grid/RotationGrid.java | // Path: src/main/java/de/mfo/jsurf/rendering/cpu/CPUAlgebraicSurfaceRenderer.java
// public enum AntiAliasingMode
// {
// SUPERSAMPLING,
// ADAPTIVE_SUPERSAMPLING;
// }
| import java.net.URL;
import java.util.*;
import java.io.*;
import org.apache.commons.cli.*;
import de.mfo.jsurf.algebra.*;
import de.mfo.jsurf.parser.*;
import de.mfo.jsurf.rendering.*;
import de.mfo.jsurf.rendering.cpu.*;
import de.mfo.jsurf.util.*;
import static de.mfo.jsurf.rendering.cpu.CPUAlgebraicSurfaceRenderer.AntiAliasingMode;
import java.awt.Graphics2D;
import java.awt.image.*;
import java.awt.Point;
import java.awt.geom.*;
import javax.vecmath.*;
import javax.imageio.*; | /*
* Copyright 2008 Christian Stussak
*
* 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 de.mfo.jsurf.grid;
// input/output
public class RotationGrid
{
static CPUAlgebraicSurfaceRenderer asr;
static Matrix4d additional_rotation;
static Matrix4d basic_rotation;
static Matrix4d scale;
static int size; | // Path: src/main/java/de/mfo/jsurf/rendering/cpu/CPUAlgebraicSurfaceRenderer.java
// public enum AntiAliasingMode
// {
// SUPERSAMPLING,
// ADAPTIVE_SUPERSAMPLING;
// }
// Path: src/main/java/de/mfo/jsurf/grid/RotationGrid.java
import java.net.URL;
import java.util.*;
import java.io.*;
import org.apache.commons.cli.*;
import de.mfo.jsurf.algebra.*;
import de.mfo.jsurf.parser.*;
import de.mfo.jsurf.rendering.*;
import de.mfo.jsurf.rendering.cpu.*;
import de.mfo.jsurf.util.*;
import static de.mfo.jsurf.rendering.cpu.CPUAlgebraicSurfaceRenderer.AntiAliasingMode;
import java.awt.Graphics2D;
import java.awt.image.*;
import java.awt.Point;
import java.awt.geom.*;
import javax.vecmath.*;
import javax.imageio.*;
/*
* Copyright 2008 Christian Stussak
*
* 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 de.mfo.jsurf.grid;
// input/output
public class RotationGrid
{
static CPUAlgebraicSurfaceRenderer asr;
static Matrix4d additional_rotation;
static Matrix4d basic_rotation;
static Matrix4d scale;
static int size; | static AntiAliasingMode aam; |
mobilejazz/CacheIO | cacheio-serializers/cacheio-gson-serializer/src/main/java/com/mobilejazz/cacheio/serializers/gson/GsonValueMapper.java | // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/ValueMapper.java
// public interface ValueMapper {
//
// void write(Object value, OutputStream out) throws SerializerException;
//
// <T> T read(Class<T> type, InputStream in) throws SerializerException;
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/exceptions/SerializerException.java
// public class SerializerException extends CacheIOException {
//
// public SerializerException() {
// }
//
// public SerializerException(String detailMessage) {
// super(detailMessage);
// }
//
// public SerializerException(String detailMessage, Throwable throwable) {
// super(detailMessage, throwable);
// }
//
// public SerializerException(Throwable throwable) {
// super(throwable);
// }
// }
| import com.google.gson.Gson;
import com.mobilejazz.cacheio.mappers.ValueMapper;
import com.mobilejazz.cacheio.exceptions.SerializerException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream; | package com.mobilejazz.cacheio.serializers.gson;
public class GsonValueMapper implements ValueMapper {
private Gson gson;
public GsonValueMapper(Gson gson) {
this.gson = gson;
}
@Override | // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/ValueMapper.java
// public interface ValueMapper {
//
// void write(Object value, OutputStream out) throws SerializerException;
//
// <T> T read(Class<T> type, InputStream in) throws SerializerException;
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/exceptions/SerializerException.java
// public class SerializerException extends CacheIOException {
//
// public SerializerException() {
// }
//
// public SerializerException(String detailMessage) {
// super(detailMessage);
// }
//
// public SerializerException(String detailMessage, Throwable throwable) {
// super(detailMessage, throwable);
// }
//
// public SerializerException(Throwable throwable) {
// super(throwable);
// }
// }
// Path: cacheio-serializers/cacheio-gson-serializer/src/main/java/com/mobilejazz/cacheio/serializers/gson/GsonValueMapper.java
import com.google.gson.Gson;
import com.mobilejazz.cacheio.mappers.ValueMapper;
import com.mobilejazz.cacheio.exceptions.SerializerException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
package com.mobilejazz.cacheio.serializers.gson;
public class GsonValueMapper implements ValueMapper {
private Gson gson;
public GsonValueMapper(Gson gson) {
this.gson = gson;
}
@Override | public void write(Object value, OutputStream out) throws SerializerException { |
mobilejazz/CacheIO | cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/key/StringKeyMapper.java | // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/KeyMapper.java
// public interface KeyMapper<T> {
//
// String toString(T model);
//
// T fromString(String str);
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
| import com.mobilejazz.cacheio.mappers.KeyMapper;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument; | package com.mobilejazz.cacheio.mappers.key;
public class StringKeyMapper implements KeyMapper<String> {
@Override public String toString(String model) { | // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/KeyMapper.java
// public interface KeyMapper<T> {
//
// String toString(T model);
//
// T fromString(String str);
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/key/StringKeyMapper.java
import com.mobilejazz.cacheio.mappers.KeyMapper;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument;
package com.mobilejazz.cacheio.mappers.key;
public class StringKeyMapper implements KeyMapper<String> {
@Override public String toString(String model) { | checkArgument(model, "key cannot be null"); |
mobilejazz/CacheIO | cacheio-repository/src/main/java/com/mobilejazz/cacheio/StringKeyedRxRepository.java | // Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/Query.java
// public interface Query {
//
// String getId();
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static String checkIsEmpty(String object, String message) {
// if (TextUtils.isEmpty(object)) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
| import com.mobilejazz.cacheio.query.Query;
import rx.Single;
import rx.functions.Func1;
import java.util.*;
import java.util.concurrent.*;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument;
import static com.mobilejazz.cacheio.helper.Preconditions.checkIsEmpty; | /*
* Copyright (C) 2016 Mobile Jazz
*
* 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.mobilejazz.cacheio;
public class StringKeyedRxRepository<M extends HasId<String>, Q extends Query>
implements RxRepository<String, M, Q> {
private Builder<M, Q> proto;
public StringKeyedRxRepository(Builder<M, Q> proto) {
this.proto = proto;
}
@Override public Single<List<M>> find(Q query) { | // Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/Query.java
// public interface Query {
//
// String getId();
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static String checkIsEmpty(String object, String message) {
// if (TextUtils.isEmpty(object)) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/StringKeyedRxRepository.java
import com.mobilejazz.cacheio.query.Query;
import rx.Single;
import rx.functions.Func1;
import java.util.*;
import java.util.concurrent.*;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument;
import static com.mobilejazz.cacheio.helper.Preconditions.checkIsEmpty;
/*
* Copyright (C) 2016 Mobile Jazz
*
* 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.mobilejazz.cacheio;
public class StringKeyedRxRepository<M extends HasId<String>, Q extends Query>
implements RxRepository<String, M, Q> {
private Builder<M, Q> proto;
public StringKeyedRxRepository(Builder<M, Q> proto) {
this.proto = proto;
}
@Override public Single<List<M>> find(Q query) { | checkArgument(query, "Query == null"); |
mobilejazz/CacheIO | cacheio-repository/src/main/java/com/mobilejazz/cacheio/StringKeyedRxRepository.java | // Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/Query.java
// public interface Query {
//
// String getId();
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static String checkIsEmpty(String object, String message) {
// if (TextUtils.isEmpty(object)) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
| import com.mobilejazz.cacheio.query.Query;
import rx.Single;
import rx.functions.Func1;
import java.util.*;
import java.util.concurrent.*;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument;
import static com.mobilejazz.cacheio.helper.Preconditions.checkIsEmpty; | /*
* Copyright (C) 2016 Mobile Jazz
*
* 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.mobilejazz.cacheio;
public class StringKeyedRxRepository<M extends HasId<String>, Q extends Query>
implements RxRepository<String, M, Q> {
private Builder<M, Q> proto;
public StringKeyedRxRepository(Builder<M, Q> proto) {
this.proto = proto;
}
@Override public Single<List<M>> find(Q query) {
checkArgument(query, "Query == null");
return proto.queryCache.get(query).flatMap(new Func1<StringList, Single<List<M>>>() {
@Override public Single<List<M>> call(StringList stringIdList) {
final List<String> ids =
stringIdList == null ? Collections.<String>emptyList() : stringIdList.getIds();
Single<Map<String, M>> valueLookup = proto.cache.getAll(ids);
return valueLookup.map(new Func1<Map<String, M>, List<M>>() {
@Override public List<M> call(Map<String, M> map) {
List<M> values = new ArrayList<>(map.size());
for (String id : ids) {
values.add(map.get(id));
}
return values;
}
});
}
});
}
@Override public Single<M> findById(String id) { | // Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/Query.java
// public interface Query {
//
// String getId();
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static String checkIsEmpty(String object, String message) {
// if (TextUtils.isEmpty(object)) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/StringKeyedRxRepository.java
import com.mobilejazz.cacheio.query.Query;
import rx.Single;
import rx.functions.Func1;
import java.util.*;
import java.util.concurrent.*;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument;
import static com.mobilejazz.cacheio.helper.Preconditions.checkIsEmpty;
/*
* Copyright (C) 2016 Mobile Jazz
*
* 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.mobilejazz.cacheio;
public class StringKeyedRxRepository<M extends HasId<String>, Q extends Query>
implements RxRepository<String, M, Q> {
private Builder<M, Q> proto;
public StringKeyedRxRepository(Builder<M, Q> proto) {
this.proto = proto;
}
@Override public Single<List<M>> find(Q query) {
checkArgument(query, "Query == null");
return proto.queryCache.get(query).flatMap(new Func1<StringList, Single<List<M>>>() {
@Override public Single<List<M>> call(StringList stringIdList) {
final List<String> ids =
stringIdList == null ? Collections.<String>emptyList() : stringIdList.getIds();
Single<Map<String, M>> valueLookup = proto.cache.getAll(ids);
return valueLookup.map(new Func1<Map<String, M>, List<M>>() {
@Override public List<M> call(Map<String, M> map) {
List<M> values = new ArrayList<>(map.size());
for (String id : ids) {
values.add(map.get(id));
}
return values;
}
});
}
});
}
@Override public Single<M> findById(String id) { | checkIsEmpty(id, "Id == null OR empty"); |
mobilejazz/CacheIO | cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/key/IntegerKeyMapper.java | // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/KeyMapper.java
// public interface KeyMapper<T> {
//
// String toString(T model);
//
// T fromString(String str);
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
| import com.mobilejazz.cacheio.mappers.KeyMapper;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument; | package com.mobilejazz.cacheio.mappers.key;
public class IntegerKeyMapper implements KeyMapper<Integer> {
@Override public String toString(Integer model) { | // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/KeyMapper.java
// public interface KeyMapper<T> {
//
// String toString(T model);
//
// T fromString(String str);
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/key/IntegerKeyMapper.java
import com.mobilejazz.cacheio.mappers.KeyMapper;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument;
package com.mobilejazz.cacheio.mappers.key;
public class IntegerKeyMapper implements KeyMapper<Integer> {
@Override public String toString(Integer model) { | checkArgument(model, "key cannot be null"); |
mobilejazz/CacheIO | cacheio-core/src/test/java/com/mobilejazz/cacheio/wrappers/FutureCacheWrapperTest.java | // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/RxCache.java
// public interface RxCache<K, V> {
//
// Single<V> get(K key);
//
// Single<V> put(K key, V value, long expiry, TimeUnit unit);
//
// Single<K> remove(K key);
//
// Single<Map<K, V>> getAll(Collection<K> keys);
//
// Single<Map<K, V>> putAll(Map<K, V> map, long expiry, TimeUnit unit);
//
// Single<Collection<K>> removeAll(Collection<K> keys);
//
// }
| import com.mobilejazz.cacheio.RxCache;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import rx.Single;
import rx.SingleSubscriber;
import java.util.*;
import java.util.concurrent.*;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; | package com.mobilejazz.cacheio.wrappers;
@SuppressWarnings("unchecked") @RunWith(MockitoJUnitRunner.class)
public class FutureCacheWrapperTest {
| // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/RxCache.java
// public interface RxCache<K, V> {
//
// Single<V> get(K key);
//
// Single<V> put(K key, V value, long expiry, TimeUnit unit);
//
// Single<K> remove(K key);
//
// Single<Map<K, V>> getAll(Collection<K> keys);
//
// Single<Map<K, V>> putAll(Map<K, V> map, long expiry, TimeUnit unit);
//
// Single<Collection<K>> removeAll(Collection<K> keys);
//
// }
// Path: cacheio-core/src/test/java/com/mobilejazz/cacheio/wrappers/FutureCacheWrapperTest.java
import com.mobilejazz.cacheio.RxCache;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import rx.Single;
import rx.SingleSubscriber;
import java.util.*;
import java.util.concurrent.*;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
package com.mobilejazz.cacheio.wrappers;
@SuppressWarnings("unchecked") @RunWith(MockitoJUnitRunner.class)
public class FutureCacheWrapperTest {
| @Mock private RxCache<String, String> delegate; |
mobilejazz/CacheIO | cacheio-repository/src/test/java/com/mobilejazz/cacheio/DefaultQueryMapperTests.java | // Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/mappers/DefaultQueryMapper.java
// public class DefaultQueryMapper implements KeyMapper<DefaultQuery> {
//
// @Override public String toString(DefaultQuery model) {
// checkArgument(model, "DefaultQuery == null");
// return model.getId();
// }
//
// @Override public DefaultQuery fromString(String str) {
// checkArgument(str, "DefaultQuery string value == null");
// return new DefaultQuery(str);
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/DefaultQuery.java
// public class DefaultQuery implements Query {
//
// private final String id;
//
// public DefaultQuery(String id) {
// this.id = id;
// }
//
// @Override public String getId() {
// return this.id;
// }
//
// @Override public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// DefaultQuery query = (DefaultQuery) o;
//
// return !(id != null ? !id.equals(query.id) : query.id != null);
//
// }
//
// @Override public int hashCode() {
// return id != null ? id.hashCode() : 0;
// }
// }
| import com.mobilejazz.cacheio.mappers.DefaultQueryMapper;
import com.mobilejazz.cacheio.query.DefaultQuery;
import org.junit.Before;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat; | /*
* Copyright (C) 2016 Mobile Jazz
*
* 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.mobilejazz.cacheio;
public class DefaultQueryMapperTests {
private DefaultQueryMapper mapper;
public static final String FAKE_QUERY = "fake.query";
@Before public void setUp() throws Exception {
mapper = new DefaultQueryMapper();
}
@Test(expected = IllegalArgumentException.class) @SuppressWarnings("ResultOfMethodCallIgnored")
public void shouldThrowIllegalArgumentExceptionIfMappingToStringWithNullValue() {
mapper.toString(null);
}
@Test(expected = IllegalArgumentException.class) @SuppressWarnings("ResultOfMethodCallIgnored")
public void shouldThrowIllegalArgumentExceptionIfMappingFromStringWithNullValue() {
mapper.fromString(null);
}
@Test public void shouldMappingToDefaultQueryToStringValue() throws Exception {
String value = mapper.toString(givenAFakeDefaultQuery());
assertThat(value).isNotNull();
assertThat(value).isEqualTo(FAKE_QUERY);
}
@Test public void shouldMappingFromStringToDefaultQuery() throws Exception { | // Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/mappers/DefaultQueryMapper.java
// public class DefaultQueryMapper implements KeyMapper<DefaultQuery> {
//
// @Override public String toString(DefaultQuery model) {
// checkArgument(model, "DefaultQuery == null");
// return model.getId();
// }
//
// @Override public DefaultQuery fromString(String str) {
// checkArgument(str, "DefaultQuery string value == null");
// return new DefaultQuery(str);
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/DefaultQuery.java
// public class DefaultQuery implements Query {
//
// private final String id;
//
// public DefaultQuery(String id) {
// this.id = id;
// }
//
// @Override public String getId() {
// return this.id;
// }
//
// @Override public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// DefaultQuery query = (DefaultQuery) o;
//
// return !(id != null ? !id.equals(query.id) : query.id != null);
//
// }
//
// @Override public int hashCode() {
// return id != null ? id.hashCode() : 0;
// }
// }
// Path: cacheio-repository/src/test/java/com/mobilejazz/cacheio/DefaultQueryMapperTests.java
import com.mobilejazz.cacheio.mappers.DefaultQueryMapper;
import com.mobilejazz.cacheio.query.DefaultQuery;
import org.junit.Before;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
/*
* Copyright (C) 2016 Mobile Jazz
*
* 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.mobilejazz.cacheio;
public class DefaultQueryMapperTests {
private DefaultQueryMapper mapper;
public static final String FAKE_QUERY = "fake.query";
@Before public void setUp() throws Exception {
mapper = new DefaultQueryMapper();
}
@Test(expected = IllegalArgumentException.class) @SuppressWarnings("ResultOfMethodCallIgnored")
public void shouldThrowIllegalArgumentExceptionIfMappingToStringWithNullValue() {
mapper.toString(null);
}
@Test(expected = IllegalArgumentException.class) @SuppressWarnings("ResultOfMethodCallIgnored")
public void shouldThrowIllegalArgumentExceptionIfMappingFromStringWithNullValue() {
mapper.fromString(null);
}
@Test public void shouldMappingToDefaultQueryToStringValue() throws Exception {
String value = mapper.toString(givenAFakeDefaultQuery());
assertThat(value).isNotNull();
assertThat(value).isEqualTo(FAKE_QUERY);
}
@Test public void shouldMappingFromStringToDefaultQuery() throws Exception { | DefaultQuery query = mapper.fromString(FAKE_QUERY); |
mobilejazz/CacheIO | cacheio-core/src/test/java/com/mobilejazz/cacheio/caches/TestValueMapper.java | // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/ValueMapper.java
// public interface ValueMapper {
//
// void write(Object value, OutputStream out) throws SerializerException;
//
// <T> T read(Class<T> type, InputStream in) throws SerializerException;
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/exceptions/SerializerException.java
// public class SerializerException extends CacheIOException {
//
// public SerializerException() {
// }
//
// public SerializerException(String detailMessage) {
// super(detailMessage);
// }
//
// public SerializerException(String detailMessage, Throwable throwable) {
// super(detailMessage, throwable);
// }
//
// public SerializerException(Throwable throwable) {
// super(throwable);
// }
// }
| import com.mobilejazz.cacheio.mappers.ValueMapper;
import com.mobilejazz.cacheio.exceptions.SerializerException;
import java.io.*;
import java.util.*;
import java.util.concurrent.*; | /*
* Copyright (C) 2016 Mobile Jazz
*
* 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.mobilejazz.cacheio.caches;
public class TestValueMapper implements ValueMapper {
private final Random random = new Random();
private final Map<SerializedValue, Object> bytesToValue = new ConcurrentHashMap<>();
| // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/ValueMapper.java
// public interface ValueMapper {
//
// void write(Object value, OutputStream out) throws SerializerException;
//
// <T> T read(Class<T> type, InputStream in) throws SerializerException;
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/exceptions/SerializerException.java
// public class SerializerException extends CacheIOException {
//
// public SerializerException() {
// }
//
// public SerializerException(String detailMessage) {
// super(detailMessage);
// }
//
// public SerializerException(String detailMessage, Throwable throwable) {
// super(detailMessage, throwable);
// }
//
// public SerializerException(Throwable throwable) {
// super(throwable);
// }
// }
// Path: cacheio-core/src/test/java/com/mobilejazz/cacheio/caches/TestValueMapper.java
import com.mobilejazz.cacheio.mappers.ValueMapper;
import com.mobilejazz.cacheio.exceptions.SerializerException;
import java.io.*;
import java.util.*;
import java.util.concurrent.*;
/*
* Copyright (C) 2016 Mobile Jazz
*
* 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.mobilejazz.cacheio.caches;
public class TestValueMapper implements ValueMapper {
private final Random random = new Random();
private final Map<SerializedValue, Object> bytesToValue = new ConcurrentHashMap<>();
| @Override public void write(Object value, OutputStream out) throws SerializerException { |
mobilejazz/CacheIO | cacheio-core/src/main/java/com/mobilejazz/cacheio/caches/SQLiteRxCache.java | // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/RxCache.java
// public interface RxCache<K, V> {
//
// Single<V> get(K key);
//
// Single<V> put(K key, V value, long expiry, TimeUnit unit);
//
// Single<K> remove(K key);
//
// Single<Map<K, V>> getAll(Collection<K> keys);
//
// Single<Map<K, V>> putAll(Map<K, V> map, long expiry, TimeUnit unit);
//
// Single<Collection<K>> removeAll(Collection<K> keys);
//
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/KeyMapper.java
// public interface KeyMapper<T> {
//
// String toString(T model);
//
// T fromString(String str);
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/ValueMapper.java
// public interface ValueMapper {
//
// void write(Object value, OutputStream out) throws SerializerException;
//
// <T> T read(Class<T> type, InputStream in) throws SerializerException;
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/VersionMapper.java
// public interface VersionMapper<T> {
//
// public static final Long UNVERSIONED = -1L;
//
// long getVersion(T model);
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/version/NoOpVersionMapper.java
// public class NoOpVersionMapper<T> implements VersionMapper<T> {
//
// @Override public long getVersion(T model) {
// return UNVERSIONED;
// }
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
| import java.util.concurrent.*;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.mobilejazz.cacheio.RxCache;
import com.mobilejazz.cacheio.mappers.KeyMapper;
import com.mobilejazz.cacheio.mappers.ValueMapper;
import com.mobilejazz.cacheio.mappers.VersionMapper;
import com.mobilejazz.cacheio.mappers.version.NoOpVersionMapper;
import rx.Single;
import rx.SingleSubscriber;
import rx.functions.Func1;
import java.io.*;
import java.util.*; | private final SingleSubscriber<? super Map<K, V>> subscriber;
private final Date now = new Date();
public GetAll(Collection<K> keys, SingleSubscriber<? super Map<K, V>> subscriber) {
this.keys = keys;
this.subscriber = subscriber;
}
@Override public void run() {
try {
final String timeStr = Long.toString(now.getTime());
final String sql = "SELECT * FROM "
+ config.tableName
+ " WHERE "
+ COLUMN_EXPIRES
+ " >= ? AND "
+ COLUMN_KEY
+ " IN ("
+ generatePlaceholders(keys.size())
+ ")";
final String[] keysAsStrings = keysAsString(keys);
final String[] args = new String[keysAsStrings.length + 1];
args[0] = timeStr;
System.arraycopy(keysAsStrings, 0, args, 1, keysAsStrings.length);
| // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/RxCache.java
// public interface RxCache<K, V> {
//
// Single<V> get(K key);
//
// Single<V> put(K key, V value, long expiry, TimeUnit unit);
//
// Single<K> remove(K key);
//
// Single<Map<K, V>> getAll(Collection<K> keys);
//
// Single<Map<K, V>> putAll(Map<K, V> map, long expiry, TimeUnit unit);
//
// Single<Collection<K>> removeAll(Collection<K> keys);
//
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/KeyMapper.java
// public interface KeyMapper<T> {
//
// String toString(T model);
//
// T fromString(String str);
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/ValueMapper.java
// public interface ValueMapper {
//
// void write(Object value, OutputStream out) throws SerializerException;
//
// <T> T read(Class<T> type, InputStream in) throws SerializerException;
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/VersionMapper.java
// public interface VersionMapper<T> {
//
// public static final Long UNVERSIONED = -1L;
//
// long getVersion(T model);
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/version/NoOpVersionMapper.java
// public class NoOpVersionMapper<T> implements VersionMapper<T> {
//
// @Override public long getVersion(T model) {
// return UNVERSIONED;
// }
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/caches/SQLiteRxCache.java
import java.util.concurrent.*;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.mobilejazz.cacheio.RxCache;
import com.mobilejazz.cacheio.mappers.KeyMapper;
import com.mobilejazz.cacheio.mappers.ValueMapper;
import com.mobilejazz.cacheio.mappers.VersionMapper;
import com.mobilejazz.cacheio.mappers.version.NoOpVersionMapper;
import rx.Single;
import rx.SingleSubscriber;
import rx.functions.Func1;
import java.io.*;
import java.util.*;
private final SingleSubscriber<? super Map<K, V>> subscriber;
private final Date now = new Date();
public GetAll(Collection<K> keys, SingleSubscriber<? super Map<K, V>> subscriber) {
this.keys = keys;
this.subscriber = subscriber;
}
@Override public void run() {
try {
final String timeStr = Long.toString(now.getTime());
final String sql = "SELECT * FROM "
+ config.tableName
+ " WHERE "
+ COLUMN_EXPIRES
+ " >= ? AND "
+ COLUMN_KEY
+ " IN ("
+ generatePlaceholders(keys.size())
+ ")";
final String[] keysAsStrings = keysAsString(keys);
final String[] args = new String[keysAsStrings.length + 1];
args[0] = timeStr;
System.arraycopy(keysAsStrings, 0, args, 1, keysAsStrings.length);
| final ValueMapper valueValueMapper = config.valueMapper; |
mobilejazz/CacheIO | cacheio-core/src/main/java/com/mobilejazz/cacheio/caches/SQLiteRxCache.java | // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/RxCache.java
// public interface RxCache<K, V> {
//
// Single<V> get(K key);
//
// Single<V> put(K key, V value, long expiry, TimeUnit unit);
//
// Single<K> remove(K key);
//
// Single<Map<K, V>> getAll(Collection<K> keys);
//
// Single<Map<K, V>> putAll(Map<K, V> map, long expiry, TimeUnit unit);
//
// Single<Collection<K>> removeAll(Collection<K> keys);
//
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/KeyMapper.java
// public interface KeyMapper<T> {
//
// String toString(T model);
//
// T fromString(String str);
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/ValueMapper.java
// public interface ValueMapper {
//
// void write(Object value, OutputStream out) throws SerializerException;
//
// <T> T read(Class<T> type, InputStream in) throws SerializerException;
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/VersionMapper.java
// public interface VersionMapper<T> {
//
// public static final Long UNVERSIONED = -1L;
//
// long getVersion(T model);
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/version/NoOpVersionMapper.java
// public class NoOpVersionMapper<T> implements VersionMapper<T> {
//
// @Override public long getVersion(T model) {
// return UNVERSIONED;
// }
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
| import java.util.concurrent.*;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.mobilejazz.cacheio.RxCache;
import com.mobilejazz.cacheio.mappers.KeyMapper;
import com.mobilejazz.cacheio.mappers.ValueMapper;
import com.mobilejazz.cacheio.mappers.VersionMapper;
import com.mobilejazz.cacheio.mappers.version.NoOpVersionMapper;
import rx.Single;
import rx.SingleSubscriber;
import rx.functions.Func1;
import java.io.*;
import java.util.*; |
subscriber.onSuccess(result);
} catch (Throwable t) {
subscriber.onError(t);
}
}
}
private final class PutAll implements Runnable {
private final Map<K, V> map;
private final long expiry;
private final TimeUnit expiryUnit;
private final SingleSubscriber<? super Map<K, V>> subscriber;
private final Date now = new Date();
public PutAll(Map<K, V> map, long expiry, TimeUnit expiryUnit,
SingleSubscriber<? super Map<K, V>> subscriber) {
this.map = map;
this.expiry = expiry;
this.expiryUnit = expiryUnit;
this.subscriber = subscriber;
}
@Override public void run() {
final SQLiteDatabase db = config.db; | // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/RxCache.java
// public interface RxCache<K, V> {
//
// Single<V> get(K key);
//
// Single<V> put(K key, V value, long expiry, TimeUnit unit);
//
// Single<K> remove(K key);
//
// Single<Map<K, V>> getAll(Collection<K> keys);
//
// Single<Map<K, V>> putAll(Map<K, V> map, long expiry, TimeUnit unit);
//
// Single<Collection<K>> removeAll(Collection<K> keys);
//
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/KeyMapper.java
// public interface KeyMapper<T> {
//
// String toString(T model);
//
// T fromString(String str);
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/ValueMapper.java
// public interface ValueMapper {
//
// void write(Object value, OutputStream out) throws SerializerException;
//
// <T> T read(Class<T> type, InputStream in) throws SerializerException;
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/VersionMapper.java
// public interface VersionMapper<T> {
//
// public static final Long UNVERSIONED = -1L;
//
// long getVersion(T model);
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/version/NoOpVersionMapper.java
// public class NoOpVersionMapper<T> implements VersionMapper<T> {
//
// @Override public long getVersion(T model) {
// return UNVERSIONED;
// }
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/caches/SQLiteRxCache.java
import java.util.concurrent.*;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.mobilejazz.cacheio.RxCache;
import com.mobilejazz.cacheio.mappers.KeyMapper;
import com.mobilejazz.cacheio.mappers.ValueMapper;
import com.mobilejazz.cacheio.mappers.VersionMapper;
import com.mobilejazz.cacheio.mappers.version.NoOpVersionMapper;
import rx.Single;
import rx.SingleSubscriber;
import rx.functions.Func1;
import java.io.*;
import java.util.*;
subscriber.onSuccess(result);
} catch (Throwable t) {
subscriber.onError(t);
}
}
}
private final class PutAll implements Runnable {
private final Map<K, V> map;
private final long expiry;
private final TimeUnit expiryUnit;
private final SingleSubscriber<? super Map<K, V>> subscriber;
private final Date now = new Date();
public PutAll(Map<K, V> map, long expiry, TimeUnit expiryUnit,
SingleSubscriber<? super Map<K, V>> subscriber) {
this.map = map;
this.expiry = expiry;
this.expiryUnit = expiryUnit;
this.subscriber = subscriber;
}
@Override public void run() {
final SQLiteDatabase db = config.db; | final KeyMapper<K> keyMapper = config.keyMapper; |
mobilejazz/CacheIO | cacheio-core/src/main/java/com/mobilejazz/cacheio/caches/SQLiteRxCache.java | // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/RxCache.java
// public interface RxCache<K, V> {
//
// Single<V> get(K key);
//
// Single<V> put(K key, V value, long expiry, TimeUnit unit);
//
// Single<K> remove(K key);
//
// Single<Map<K, V>> getAll(Collection<K> keys);
//
// Single<Map<K, V>> putAll(Map<K, V> map, long expiry, TimeUnit unit);
//
// Single<Collection<K>> removeAll(Collection<K> keys);
//
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/KeyMapper.java
// public interface KeyMapper<T> {
//
// String toString(T model);
//
// T fromString(String str);
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/ValueMapper.java
// public interface ValueMapper {
//
// void write(Object value, OutputStream out) throws SerializerException;
//
// <T> T read(Class<T> type, InputStream in) throws SerializerException;
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/VersionMapper.java
// public interface VersionMapper<T> {
//
// public static final Long UNVERSIONED = -1L;
//
// long getVersion(T model);
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/version/NoOpVersionMapper.java
// public class NoOpVersionMapper<T> implements VersionMapper<T> {
//
// @Override public long getVersion(T model) {
// return UNVERSIONED;
// }
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
| import java.util.concurrent.*;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.mobilejazz.cacheio.RxCache;
import com.mobilejazz.cacheio.mappers.KeyMapper;
import com.mobilejazz.cacheio.mappers.ValueMapper;
import com.mobilejazz.cacheio.mappers.VersionMapper;
import com.mobilejazz.cacheio.mappers.version.NoOpVersionMapper;
import rx.Single;
import rx.SingleSubscriber;
import rx.functions.Func1;
import java.io.*;
import java.util.*; | subscriber.onSuccess(result);
} catch (Throwable t) {
subscriber.onError(t);
}
}
}
private final class PutAll implements Runnable {
private final Map<K, V> map;
private final long expiry;
private final TimeUnit expiryUnit;
private final SingleSubscriber<? super Map<K, V>> subscriber;
private final Date now = new Date();
public PutAll(Map<K, V> map, long expiry, TimeUnit expiryUnit,
SingleSubscriber<? super Map<K, V>> subscriber) {
this.map = map;
this.expiry = expiry;
this.expiryUnit = expiryUnit;
this.subscriber = subscriber;
}
@Override public void run() {
final SQLiteDatabase db = config.db;
final KeyMapper<K> keyMapper = config.keyMapper; | // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/RxCache.java
// public interface RxCache<K, V> {
//
// Single<V> get(K key);
//
// Single<V> put(K key, V value, long expiry, TimeUnit unit);
//
// Single<K> remove(K key);
//
// Single<Map<K, V>> getAll(Collection<K> keys);
//
// Single<Map<K, V>> putAll(Map<K, V> map, long expiry, TimeUnit unit);
//
// Single<Collection<K>> removeAll(Collection<K> keys);
//
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/KeyMapper.java
// public interface KeyMapper<T> {
//
// String toString(T model);
//
// T fromString(String str);
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/ValueMapper.java
// public interface ValueMapper {
//
// void write(Object value, OutputStream out) throws SerializerException;
//
// <T> T read(Class<T> type, InputStream in) throws SerializerException;
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/VersionMapper.java
// public interface VersionMapper<T> {
//
// public static final Long UNVERSIONED = -1L;
//
// long getVersion(T model);
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/version/NoOpVersionMapper.java
// public class NoOpVersionMapper<T> implements VersionMapper<T> {
//
// @Override public long getVersion(T model) {
// return UNVERSIONED;
// }
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/caches/SQLiteRxCache.java
import java.util.concurrent.*;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.mobilejazz.cacheio.RxCache;
import com.mobilejazz.cacheio.mappers.KeyMapper;
import com.mobilejazz.cacheio.mappers.ValueMapper;
import com.mobilejazz.cacheio.mappers.VersionMapper;
import com.mobilejazz.cacheio.mappers.version.NoOpVersionMapper;
import rx.Single;
import rx.SingleSubscriber;
import rx.functions.Func1;
import java.io.*;
import java.util.*;
subscriber.onSuccess(result);
} catch (Throwable t) {
subscriber.onError(t);
}
}
}
private final class PutAll implements Runnable {
private final Map<K, V> map;
private final long expiry;
private final TimeUnit expiryUnit;
private final SingleSubscriber<? super Map<K, V>> subscriber;
private final Date now = new Date();
public PutAll(Map<K, V> map, long expiry, TimeUnit expiryUnit,
SingleSubscriber<? super Map<K, V>> subscriber) {
this.map = map;
this.expiry = expiry;
this.expiryUnit = expiryUnit;
this.subscriber = subscriber;
}
@Override public void run() {
final SQLiteDatabase db = config.db;
final KeyMapper<K> keyMapper = config.keyMapper; | final VersionMapper<V> versionMapper = config.versionMapper; |
mobilejazz/CacheIO | cacheio-core/src/main/java/com/mobilejazz/cacheio/caches/SQLiteRxCache.java | // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/RxCache.java
// public interface RxCache<K, V> {
//
// Single<V> get(K key);
//
// Single<V> put(K key, V value, long expiry, TimeUnit unit);
//
// Single<K> remove(K key);
//
// Single<Map<K, V>> getAll(Collection<K> keys);
//
// Single<Map<K, V>> putAll(Map<K, V> map, long expiry, TimeUnit unit);
//
// Single<Collection<K>> removeAll(Collection<K> keys);
//
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/KeyMapper.java
// public interface KeyMapper<T> {
//
// String toString(T model);
//
// T fromString(String str);
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/ValueMapper.java
// public interface ValueMapper {
//
// void write(Object value, OutputStream out) throws SerializerException;
//
// <T> T read(Class<T> type, InputStream in) throws SerializerException;
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/VersionMapper.java
// public interface VersionMapper<T> {
//
// public static final Long UNVERSIONED = -1L;
//
// long getVersion(T model);
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/version/NoOpVersionMapper.java
// public class NoOpVersionMapper<T> implements VersionMapper<T> {
//
// @Override public long getVersion(T model) {
// return UNVERSIONED;
// }
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
| import java.util.concurrent.*;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.mobilejazz.cacheio.RxCache;
import com.mobilejazz.cacheio.mappers.KeyMapper;
import com.mobilejazz.cacheio.mappers.ValueMapper;
import com.mobilejazz.cacheio.mappers.VersionMapper;
import com.mobilejazz.cacheio.mappers.version.NoOpVersionMapper;
import rx.Single;
import rx.SingleSubscriber;
import rx.functions.Func1;
import java.io.*;
import java.util.*; | try {
final Map<K, V> result = new HashMap<>(map.size());
final long createdAt = now.getTime();
final long expiresAt =
expiry == Long.MAX_VALUE ? expiry : createdAt + expiryUnit.toMillis(expiry);
db.beginTransaction();
final Set<K> keys = map.keySet();
final Set<K> keysToUpdate = new HashSet<>(keys);
final String versionSql = "SELECT " + COLUMN_KEY + ", " + COLUMN_VERSION + " FROM " +
config.tableName + " WHERE key in (" + generatePlaceholders(keys.size()) + ")";
final Cursor versionCursor = config.db.rawQuery(versionSql, keysAsString(keys));
// determine based on version which keys we should update
while (versionCursor.moveToNext()) {
final K key = keyMapper.fromString(
versionCursor.getString(versionCursor.getColumnIndex(COLUMN_KEY)));
final long version = versionCursor.getLong(versionCursor.getColumnIndex(COLUMN_VERSION));
final V value = map.get(key);
final long valueVersion = versionMapper.getVersion(value);
| // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/RxCache.java
// public interface RxCache<K, V> {
//
// Single<V> get(K key);
//
// Single<V> put(K key, V value, long expiry, TimeUnit unit);
//
// Single<K> remove(K key);
//
// Single<Map<K, V>> getAll(Collection<K> keys);
//
// Single<Map<K, V>> putAll(Map<K, V> map, long expiry, TimeUnit unit);
//
// Single<Collection<K>> removeAll(Collection<K> keys);
//
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/KeyMapper.java
// public interface KeyMapper<T> {
//
// String toString(T model);
//
// T fromString(String str);
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/ValueMapper.java
// public interface ValueMapper {
//
// void write(Object value, OutputStream out) throws SerializerException;
//
// <T> T read(Class<T> type, InputStream in) throws SerializerException;
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/VersionMapper.java
// public interface VersionMapper<T> {
//
// public static final Long UNVERSIONED = -1L;
//
// long getVersion(T model);
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/version/NoOpVersionMapper.java
// public class NoOpVersionMapper<T> implements VersionMapper<T> {
//
// @Override public long getVersion(T model) {
// return UNVERSIONED;
// }
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/caches/SQLiteRxCache.java
import java.util.concurrent.*;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.mobilejazz.cacheio.RxCache;
import com.mobilejazz.cacheio.mappers.KeyMapper;
import com.mobilejazz.cacheio.mappers.ValueMapper;
import com.mobilejazz.cacheio.mappers.VersionMapper;
import com.mobilejazz.cacheio.mappers.version.NoOpVersionMapper;
import rx.Single;
import rx.SingleSubscriber;
import rx.functions.Func1;
import java.io.*;
import java.util.*;
try {
final Map<K, V> result = new HashMap<>(map.size());
final long createdAt = now.getTime();
final long expiresAt =
expiry == Long.MAX_VALUE ? expiry : createdAt + expiryUnit.toMillis(expiry);
db.beginTransaction();
final Set<K> keys = map.keySet();
final Set<K> keysToUpdate = new HashSet<>(keys);
final String versionSql = "SELECT " + COLUMN_KEY + ", " + COLUMN_VERSION + " FROM " +
config.tableName + " WHERE key in (" + generatePlaceholders(keys.size()) + ")";
final Cursor versionCursor = config.db.rawQuery(versionSql, keysAsString(keys));
// determine based on version which keys we should update
while (versionCursor.moveToNext()) {
final K key = keyMapper.fromString(
versionCursor.getString(versionCursor.getColumnIndex(COLUMN_KEY)));
final long version = versionCursor.getLong(versionCursor.getColumnIndex(COLUMN_VERSION));
final V value = map.get(key);
final long valueVersion = versionMapper.getVersion(value);
| if (valueVersion != NoOpVersionMapper.UNVERSIONED |
mobilejazz/CacheIO | cacheio-core/src/main/java/com/mobilejazz/cacheio/caches/SQLiteRxCache.java | // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/RxCache.java
// public interface RxCache<K, V> {
//
// Single<V> get(K key);
//
// Single<V> put(K key, V value, long expiry, TimeUnit unit);
//
// Single<K> remove(K key);
//
// Single<Map<K, V>> getAll(Collection<K> keys);
//
// Single<Map<K, V>> putAll(Map<K, V> map, long expiry, TimeUnit unit);
//
// Single<Collection<K>> removeAll(Collection<K> keys);
//
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/KeyMapper.java
// public interface KeyMapper<T> {
//
// String toString(T model);
//
// T fromString(String str);
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/ValueMapper.java
// public interface ValueMapper {
//
// void write(Object value, OutputStream out) throws SerializerException;
//
// <T> T read(Class<T> type, InputStream in) throws SerializerException;
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/VersionMapper.java
// public interface VersionMapper<T> {
//
// public static final Long UNVERSIONED = -1L;
//
// long getVersion(T model);
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/version/NoOpVersionMapper.java
// public class NoOpVersionMapper<T> implements VersionMapper<T> {
//
// @Override public long getVersion(T model) {
// return UNVERSIONED;
// }
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
| import java.util.concurrent.*;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.mobilejazz.cacheio.RxCache;
import com.mobilejazz.cacheio.mappers.KeyMapper;
import com.mobilejazz.cacheio.mappers.ValueMapper;
import com.mobilejazz.cacheio.mappers.VersionMapper;
import com.mobilejazz.cacheio.mappers.version.NoOpVersionMapper;
import rx.Single;
import rx.SingleSubscriber;
import rx.functions.Func1;
import java.io.*;
import java.util.*; | public Builder<K, V> setValueMapper(ValueMapper valueMapper) {
this.valueMapper = valueMapper;
return this;
}
public Builder<K, V> setVersionMapper(VersionMapper<V> versionMapper) {
this.versionMapper = versionMapper;
return this;
}
private void removeExpired() {
final long now = System.currentTimeMillis();
db.execSQL(String.format(DELETE_EXPIRED_SQL, tableName), new Object[] { now });
}
@SuppressWarnings("unchecked") public RxCache<K, V> build() {
// defaults
if (this.tableName == null) {
this.tableName = keyType.getName().replaceAll("\\.", "_") + "___" + valueType.getName()
.replaceAll("\\.", "_");
}
if (this.versionMapper == null) {
this.versionMapper = new NoOpVersionMapper<>();
}
// assertions
| // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/RxCache.java
// public interface RxCache<K, V> {
//
// Single<V> get(K key);
//
// Single<V> put(K key, V value, long expiry, TimeUnit unit);
//
// Single<K> remove(K key);
//
// Single<Map<K, V>> getAll(Collection<K> keys);
//
// Single<Map<K, V>> putAll(Map<K, V> map, long expiry, TimeUnit unit);
//
// Single<Collection<K>> removeAll(Collection<K> keys);
//
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/KeyMapper.java
// public interface KeyMapper<T> {
//
// String toString(T model);
//
// T fromString(String str);
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/ValueMapper.java
// public interface ValueMapper {
//
// void write(Object value, OutputStream out) throws SerializerException;
//
// <T> T read(Class<T> type, InputStream in) throws SerializerException;
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/VersionMapper.java
// public interface VersionMapper<T> {
//
// public static final Long UNVERSIONED = -1L;
//
// long getVersion(T model);
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/version/NoOpVersionMapper.java
// public class NoOpVersionMapper<T> implements VersionMapper<T> {
//
// @Override public long getVersion(T model) {
// return UNVERSIONED;
// }
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/caches/SQLiteRxCache.java
import java.util.concurrent.*;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.mobilejazz.cacheio.RxCache;
import com.mobilejazz.cacheio.mappers.KeyMapper;
import com.mobilejazz.cacheio.mappers.ValueMapper;
import com.mobilejazz.cacheio.mappers.VersionMapper;
import com.mobilejazz.cacheio.mappers.version.NoOpVersionMapper;
import rx.Single;
import rx.SingleSubscriber;
import rx.functions.Func1;
import java.io.*;
import java.util.*;
public Builder<K, V> setValueMapper(ValueMapper valueMapper) {
this.valueMapper = valueMapper;
return this;
}
public Builder<K, V> setVersionMapper(VersionMapper<V> versionMapper) {
this.versionMapper = versionMapper;
return this;
}
private void removeExpired() {
final long now = System.currentTimeMillis();
db.execSQL(String.format(DELETE_EXPIRED_SQL, tableName), new Object[] { now });
}
@SuppressWarnings("unchecked") public RxCache<K, V> build() {
// defaults
if (this.tableName == null) {
this.tableName = keyType.getName().replaceAll("\\.", "_") + "___" + valueType.getName()
.replaceAll("\\.", "_");
}
if (this.versionMapper == null) {
this.versionMapper = new NoOpVersionMapper<>();
}
// assertions
| checkArgument(db, "Database cannot be null"); |
mobilejazz/CacheIO | cacheio-repository/src/test/java/com/mobilejazz/cacheio/PaginatedQueryMapperTests.java | // Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/mappers/PaginatedQueryMapper.java
// public class PaginatedQueryMapper implements KeyMapper<PaginatedQuery> {
//
// private final static String DELIMITER = "_";
//
// @Override public String toString(PaginatedQuery model) {
// checkArgument(model, "PaginatedQuery == null");
// return String.valueOf(model.getId() + DELIMITER + model.getOffset())
// + DELIMITER
// + model.getLimit();
// }
//
// @Override public PaginatedQuery fromString(String str) {
// checkArgument(str, "PaginatedQuery string value == null");
// String[] tokens = str.split(DELIMITER);
// String id = tokens[0];
// String offset = tokens[1];
// String limit = tokens[2];
// return new PaginatedQuery(id, Integer.parseInt(offset), Integer.parseInt(limit));
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/PaginatedQuery.java
// public class PaginatedQuery implements Query {
//
// private final String id;
// private final int offset;
// private final int limit;
//
// public PaginatedQuery(String id, int offset, int limit) {
// this.id = id;
// this.offset = offset;
// this.limit = limit;
// }
//
// public int getOffset() {
// return offset;
// }
//
// public int getLimit() {
// return limit;
// }
//
// @Override public String getId() {
// return id;
// }
//
// @Override public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PaginatedQuery that = (PaginatedQuery) o;
//
// if (offset != that.offset) return false;
// if (limit != that.limit) return false;
// return id.equals(that.id);
//
// }
//
// @Override public int hashCode() {
// int result = id.hashCode();
// result = 31 * result + offset;
// result = 31 * result + limit;
// return result;
// }
// }
| import com.mobilejazz.cacheio.mappers.PaginatedQueryMapper;
import com.mobilejazz.cacheio.query.PaginatedQuery;
import org.junit.Before;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat; | /*
* Copyright (C) 2016 Mobile Jazz
*
* 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.mobilejazz.cacheio;
public class PaginatedQueryMapperTests {
public static final String FAKE_PAGINATED_QUERY_ID = "fake.paginated.query.id";
public static final int FAKE_OFFSET = 0;
public static final int FAKE_LIMIT = 10;
| // Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/mappers/PaginatedQueryMapper.java
// public class PaginatedQueryMapper implements KeyMapper<PaginatedQuery> {
//
// private final static String DELIMITER = "_";
//
// @Override public String toString(PaginatedQuery model) {
// checkArgument(model, "PaginatedQuery == null");
// return String.valueOf(model.getId() + DELIMITER + model.getOffset())
// + DELIMITER
// + model.getLimit();
// }
//
// @Override public PaginatedQuery fromString(String str) {
// checkArgument(str, "PaginatedQuery string value == null");
// String[] tokens = str.split(DELIMITER);
// String id = tokens[0];
// String offset = tokens[1];
// String limit = tokens[2];
// return new PaginatedQuery(id, Integer.parseInt(offset), Integer.parseInt(limit));
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/PaginatedQuery.java
// public class PaginatedQuery implements Query {
//
// private final String id;
// private final int offset;
// private final int limit;
//
// public PaginatedQuery(String id, int offset, int limit) {
// this.id = id;
// this.offset = offset;
// this.limit = limit;
// }
//
// public int getOffset() {
// return offset;
// }
//
// public int getLimit() {
// return limit;
// }
//
// @Override public String getId() {
// return id;
// }
//
// @Override public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PaginatedQuery that = (PaginatedQuery) o;
//
// if (offset != that.offset) return false;
// if (limit != that.limit) return false;
// return id.equals(that.id);
//
// }
//
// @Override public int hashCode() {
// int result = id.hashCode();
// result = 31 * result + offset;
// result = 31 * result + limit;
// return result;
// }
// }
// Path: cacheio-repository/src/test/java/com/mobilejazz/cacheio/PaginatedQueryMapperTests.java
import com.mobilejazz.cacheio.mappers.PaginatedQueryMapper;
import com.mobilejazz.cacheio.query.PaginatedQuery;
import org.junit.Before;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
/*
* Copyright (C) 2016 Mobile Jazz
*
* 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.mobilejazz.cacheio;
public class PaginatedQueryMapperTests {
public static final String FAKE_PAGINATED_QUERY_ID = "fake.paginated.query.id";
public static final int FAKE_OFFSET = 0;
public static final int FAKE_LIMIT = 10;
| private PaginatedQueryMapper mapper; |
mobilejazz/CacheIO | cacheio-repository/src/test/java/com/mobilejazz/cacheio/PaginatedQueryMapperTests.java | // Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/mappers/PaginatedQueryMapper.java
// public class PaginatedQueryMapper implements KeyMapper<PaginatedQuery> {
//
// private final static String DELIMITER = "_";
//
// @Override public String toString(PaginatedQuery model) {
// checkArgument(model, "PaginatedQuery == null");
// return String.valueOf(model.getId() + DELIMITER + model.getOffset())
// + DELIMITER
// + model.getLimit();
// }
//
// @Override public PaginatedQuery fromString(String str) {
// checkArgument(str, "PaginatedQuery string value == null");
// String[] tokens = str.split(DELIMITER);
// String id = tokens[0];
// String offset = tokens[1];
// String limit = tokens[2];
// return new PaginatedQuery(id, Integer.parseInt(offset), Integer.parseInt(limit));
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/PaginatedQuery.java
// public class PaginatedQuery implements Query {
//
// private final String id;
// private final int offset;
// private final int limit;
//
// public PaginatedQuery(String id, int offset, int limit) {
// this.id = id;
// this.offset = offset;
// this.limit = limit;
// }
//
// public int getOffset() {
// return offset;
// }
//
// public int getLimit() {
// return limit;
// }
//
// @Override public String getId() {
// return id;
// }
//
// @Override public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PaginatedQuery that = (PaginatedQuery) o;
//
// if (offset != that.offset) return false;
// if (limit != that.limit) return false;
// return id.equals(that.id);
//
// }
//
// @Override public int hashCode() {
// int result = id.hashCode();
// result = 31 * result + offset;
// result = 31 * result + limit;
// return result;
// }
// }
| import com.mobilejazz.cacheio.mappers.PaginatedQueryMapper;
import com.mobilejazz.cacheio.query.PaginatedQuery;
import org.junit.Before;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat; | /*
* Copyright (C) 2016 Mobile Jazz
*
* 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.mobilejazz.cacheio;
public class PaginatedQueryMapperTests {
public static final String FAKE_PAGINATED_QUERY_ID = "fake.paginated.query.id";
public static final int FAKE_OFFSET = 0;
public static final int FAKE_LIMIT = 10;
private PaginatedQueryMapper mapper;
@Before public void setUp() throws Exception {
mapper = new PaginatedQueryMapper();
}
@Test(expected = IllegalArgumentException.class) @SuppressWarnings("ResultOfMethodCallIgnored")
public void shouldThrowIllegalArgumentExceptionIfMappingToStringWithNullValue() {
mapper.toString(null);
}
@Test(expected = IllegalArgumentException.class) @SuppressWarnings("ResultOfMethodCallIgnored")
public void shouldThrowIllegalArgumentExceptionIfMappingFromStringWithNullValue() {
mapper.fromString(null);
}
@Test public void shouldMappingToPaginatedQueryToStringValue() throws Exception {
String value = mapper.toString(givenAFakePaginatedQuery());
assertThat(value).isNotNull();
assertThat(value).isEqualTo(FAKE_PAGINATED_QUERY_ID + "_" + FAKE_OFFSET + "_" + FAKE_LIMIT);
}
@Test public void shouldMappingFromStringToPaginatedQuery() throws Exception { | // Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/mappers/PaginatedQueryMapper.java
// public class PaginatedQueryMapper implements KeyMapper<PaginatedQuery> {
//
// private final static String DELIMITER = "_";
//
// @Override public String toString(PaginatedQuery model) {
// checkArgument(model, "PaginatedQuery == null");
// return String.valueOf(model.getId() + DELIMITER + model.getOffset())
// + DELIMITER
// + model.getLimit();
// }
//
// @Override public PaginatedQuery fromString(String str) {
// checkArgument(str, "PaginatedQuery string value == null");
// String[] tokens = str.split(DELIMITER);
// String id = tokens[0];
// String offset = tokens[1];
// String limit = tokens[2];
// return new PaginatedQuery(id, Integer.parseInt(offset), Integer.parseInt(limit));
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/PaginatedQuery.java
// public class PaginatedQuery implements Query {
//
// private final String id;
// private final int offset;
// private final int limit;
//
// public PaginatedQuery(String id, int offset, int limit) {
// this.id = id;
// this.offset = offset;
// this.limit = limit;
// }
//
// public int getOffset() {
// return offset;
// }
//
// public int getLimit() {
// return limit;
// }
//
// @Override public String getId() {
// return id;
// }
//
// @Override public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PaginatedQuery that = (PaginatedQuery) o;
//
// if (offset != that.offset) return false;
// if (limit != that.limit) return false;
// return id.equals(that.id);
//
// }
//
// @Override public int hashCode() {
// int result = id.hashCode();
// result = 31 * result + offset;
// result = 31 * result + limit;
// return result;
// }
// }
// Path: cacheio-repository/src/test/java/com/mobilejazz/cacheio/PaginatedQueryMapperTests.java
import com.mobilejazz.cacheio.mappers.PaginatedQueryMapper;
import com.mobilejazz.cacheio.query.PaginatedQuery;
import org.junit.Before;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
/*
* Copyright (C) 2016 Mobile Jazz
*
* 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.mobilejazz.cacheio;
public class PaginatedQueryMapperTests {
public static final String FAKE_PAGINATED_QUERY_ID = "fake.paginated.query.id";
public static final int FAKE_OFFSET = 0;
public static final int FAKE_LIMIT = 10;
private PaginatedQueryMapper mapper;
@Before public void setUp() throws Exception {
mapper = new PaginatedQueryMapper();
}
@Test(expected = IllegalArgumentException.class) @SuppressWarnings("ResultOfMethodCallIgnored")
public void shouldThrowIllegalArgumentExceptionIfMappingToStringWithNullValue() {
mapper.toString(null);
}
@Test(expected = IllegalArgumentException.class) @SuppressWarnings("ResultOfMethodCallIgnored")
public void shouldThrowIllegalArgumentExceptionIfMappingFromStringWithNullValue() {
mapper.fromString(null);
}
@Test public void shouldMappingToPaginatedQueryToStringValue() throws Exception {
String value = mapper.toString(givenAFakePaginatedQuery());
assertThat(value).isNotNull();
assertThat(value).isEqualTo(FAKE_PAGINATED_QUERY_ID + "_" + FAKE_OFFSET + "_" + FAKE_LIMIT);
}
@Test public void shouldMappingFromStringToPaginatedQuery() throws Exception { | PaginatedQuery query = |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.