id
stringlengths 36
36
| text
stringlengths 1
1.25M
|
---|---|
9f5ff23b-43ca-4db2-8b64-ac22ebfc05bf | public Api500pxStreamBuilder withTags()
{
this.tags = true;
return this;
} |
3050d542-af55-4a32-865a-321c9b347c1c | protected String urlString()
{
StringBuilder bldr = new StringBuilder(128);
bldr.append(baseUrl);
if (feature != null)
{
bldr.append("&feature=");
bldr.append(feature);
}
if (username != null)
{
bldr.append("&username=");
bldr.append(username);
}
if (user_id != null)
{
bldr.append("&user_id=");
bldr.append(user_id);
}
if (onlyCategory != null)
{
String catName = null;
try
{
catName = URLEncoder.encode(onlyCategory.getCategoryName(), "utf-8");
bldr.append("&only=");
bldr.append(catName);
}
catch (UnsupportedEncodingException e)
{
log.warn("Error encoding Url", e);
}
}
if (excludeCategory != null)
{
try
{
String catName = URLEncoder.encode(excludeCategory.getCategoryName(), "utf-8");
bldr.append("&exclude=");
bldr.append(catName);
}
catch (UnsupportedEncodingException e)
{
log.warn("Error encoding Url", e);
}
}
if (sortOrder != null)
{
try
{
String sortName = URLEncoder.encode(sortOrder.name(), "utf-8");
bldr.append("&sort=");
bldr.append(sortName);
if (sortDirection != null)
{
String sortDirectionName = URLEncoder.encode(sortDirection, "utf-8");
bldr.append("&sort_direction=");
bldr.append(sortDirectionName);
}
}
catch (UnsupportedEncodingException e)
{
log.warn("Error encoding Url", e);
}
}
if (imageSize != null)
{
bldr.append("&image_size=");
bldr.append(imageSize);
}
if (page != null)
{
bldr.append("&page=");
bldr.append(page);
}
if (rpp != null)
{
bldr.append("&rpp=");
bldr.append(rpp);
}
if (tags)
{
bldr.append("&tags=");
bldr.append(1);
}
if (store)
{
bldr.append("&include_store=");
bldr.append(1);
}
if (states)
{
bldr.append("&include_states=");
bldr.append(1);
}
log.trace(bldr.toString());
return bldr.toString();
} |
952ad156-9628-4da2-9365-dd9fd929cf9b | public FeatureResponse getResponse()
{
FeatureResponse pr = null;
try
{
OAuthService service = null;
if (privateKey != null && accessToken != null)
{
service = new ServiceBuilder().provider(Px500Api.class).apiKey(consumerKey).apiSecret(privateKey).build();
}
OAuthRequest request = new OAuthRequest(Verb.GET, urlString());
if (service != null)
{
service.signRequest(accessToken, request);
}
Response response = request.send();
String body = response.getBody();
log.trace(body);
Gson gson = GsonFactory.getGson();
pr = gson.fromJson(body, FeatureResponse.class);
pr.setBuilder(this);
}
catch (Exception badE)
{
// TODO: log this, turn it into another exception type
log.warn("Exception getting response", badE);
}
return pr;
} |
e3b806ad-1c4b-4145-8bde-fd8ac25c12d8 | public Photo getPhoto()
{
return photo;
} |
a0741461-c2a6-4604-af43-0980702c1f1b | public void setPhoto(Photo photo)
{
this.photo = photo;
} |
7f3157e5-ca46-449c-b83c-24a43c7b60d5 | public ArrayList<Comment> getComments()
{
return comments;
} |
c3d17072-7a52-4a57-a39f-2b785af33b2a | public void setComments(ArrayList<Comment> comments)
{
this.comments = comments;
} |
683c8102-974e-4b4e-83a0-d978f8f82e4a | private ConsumerKeyFinder()
{
} |
8d0cea41-9fa2-4782-b9fc-4176ed8351c2 | public static String getKey()
{
String key = System.getProperty("500PX_CONSUMER_KEY","");
if (key.isEmpty())
{
try
{
key = findFile();
}
catch (IOException ex)
{
// log or something?
}
}
return key;
} |
e482dd5c-6807-4d12-bdd4-8fa6a9e707ca | private static String findFile() throws IOException
{
String rtn = "";
File f = new File(".consumerkey");
System.out.println(f.getCanonicalPath());
if (f.exists())
{
byte[] bytes = Files.readAllBytes(f.toPath());
rtn = new String(bytes);
}
return rtn.trim();
} |
f7807b4f-4c5e-4ac7-aaa3-a503ec5c48ed | @BeforeClass
public static void checkForconsumerKey()
{
consumerKey = ConsumerKeyFinder.getKey();
if (consumerKey.isEmpty())
{
fail("Please define your consumer key");
}
} |
7647455d-df3f-48a3-b02a-81c878a6ae1d | @Test
public void testFreshYesterdayPhotoCounts()
{
FeatureResponse pr = new Api500pxStreamBuilder(consumerKey).freshYesterdayPhotos().largeThumbnails().resultsPerPage(100).getResponse();
if (pr != null)
{
int items = pr.getTotal_items();
assertTrue("Nothing returned", items > 0);
System.out.printf("Found %d items%n", items);
}
else
{
fail("No response");
}
} |
932388ff-a4df-4bf6-9147-7d2c3d0dc20c | @Test
public void testSkipCategory()
{
FeatureResponse pr = new Api500pxStreamBuilder(consumerKey).freshYesterdayPhotos().largeThumbnails().resultsPerPage(100).exclude(Category.Nature).getResponse();
if (pr != null)
{
int items = pr.getTotal_items();
System.out.printf("Found %d items%n", items);
for (Photo p : pr.getPhotos())
{
if (p.getCategory().equals(Category.Nature))
{
fail("Found an image in the exclude category");
}
}
}
else
{
fail("No response");
}
} |
b635f673-76ee-461b-9465-70fdd10bdb57 | @Test
public void testOnlyCategory()
{
FeatureResponse pr = new Api500pxStreamBuilder(consumerKey).freshYesterdayPhotos().largeThumbnails().resultsPerPage(100).only(Category.Nature).getResponse();
if (pr != null)
{
int items = pr.getTotal_items();
System.out.printf("Found %d items%n", items);
for (Photo p : pr.getPhotos())
{
if (!p.getCategory().equals(Category.Nature))
{
fail("Found an image not in the only category");
}
}
}
else
{
fail("No response");
}
} |
1174dfad-4811-42ef-926a-a866c40dbcf7 | @Test
public void dumpPhotos()
{
FeatureResponse pr = new Api500pxStreamBuilder(consumerKey).freshYesterdayPhotos().largeThumbnails().resultsPerPage(1).getResponse();
assertNotNull("No repsonse", pr);
ArrayList<Photo> photos = pr.getPhotos();
assertNotNull("Photos null", photos);
assertTrue("No photos", photos.size() > 0);
} |
656328d5-cdb7-4e03-9a9e-e65b422215fd | @Test
public void getUserPhotos()
{
FeatureResponse pr = new Api500pxStreamBuilder(consumerKey).userPhotos("ericski").sort(Sort.times_viewed).smallThumbnails().getResponse();
assertNotNull(pr);
int items = pr.getTotal_items();
int pages = pr.getTotal_pages();
System.out.printf("Found %d items in %d pages%n", items, pages);
int total_views = 0;
int rank = 0;
do
{
for (Photo p : pr.getPhotos())
{
assertNotNull(p.getUser());
assertEquals("ericski", p.getUser().getUsername());
System.out.print("Rank: " + ++rank);
System.out.print(",");
System.out.print("ID: " + p.getId());
System.out.print(",");
System.out.print("Name: " + p.getName());
System.out.print(",");
// System.out.print("URL: " + p.getImageUrl());
// System.out.print("\t");
// System.out.print("Votes: " + p.getVotesCount());
// System.out.print("\t");
// System.out.print("Favorites: " + p.getFavoritesCount());
// System.out.print("\t");
// System.out.print("Rating: " + p.getRating());
// System.out.print("\t");
System.out.print("Views: " + p.getTimesViewed());
System.out.println();
total_views += p.getTimesViewed();
// System.out.println("Comments: " + p.getCommentsCount());
}
} while ((pr = pr.getNextPage()) != null);
System.out.println("Total views: " + total_views);
} |
54355697-fd1a-4e86-8bb3-9a71c5c810f5 | @Test
public void getAllUserPhotos()
{
FeatureResponse pr = new Api500pxStreamBuilder(consumerKey).userPhotos("ericski").sort(Sort.times_viewed).smallThumbnails().getResponse();
assertNotNull(pr);
pr.getAllPhotos();
int items = pr.getTotal_items();
int pages = pr.getTotal_pages();
System.out.printf("Found %d items in %d pages%n", items, pages);
int total_views = 0;
int rank = 0;
for (Photo p : pr.getPhotos())
{
assertNotNull(p.getUser());
assertEquals("ericski", p.getUser().getUsername());
System.out.print("Rank: " + ++rank);
System.out.print(",");
System.out.print("ID: " + p.getId());
System.out.print(",");
System.out.print("Name: " + p.getName());
System.out.print(",");
// System.out.print("URL: " + p.getImageUrl());
// System.out.print("\t");
// System.out.print("Votes: " + p.getVotesCount());
// System.out.print("\t");
// System.out.print("Favorites: " + p.getFavoritesCount());
// System.out.print("\t");
// System.out.print("Rating: " + p.getRating());
// System.out.print("\t");
System.out.print("Views: " + p.getTimesViewed());
System.out.println();
total_views += p.getTimesViewed();
// System.out.println("Comments: " + p.getCommentsCount());
}
System.out.println("Total views: " + total_views);
} |
d48e4055-0f46-4515-b119-029bac37d001 | @Test
public void getUserPhotosSorted()
{
FeatureResponse pr = new Api500pxStreamBuilder(consumerKey).userPhotos("ericski").sort(Sort.times_viewed).getResponse();
assertNotNull(pr);
int items = pr.getTotal_items();
System.out.printf("getUserPhotosSorted - Found %d items%n", items);
for (Photo p : pr.getPhotos())
{
assertNotNull(p.getUser());
assertEquals("ericski", p.getUser().getUsername());
}
} |
9de127c1-6407-44d3-b03c-0ba03ba6aa34 | @Test
public void requestWithTags()
{
FeatureResponse pr = new Api500pxStreamBuilder(consumerKey).popularPhotos().resultsPerPage(2).withTags().getResponse();
assertNotNull(pr);
} |
5f3f5170-6fc1-47e2-90bc-e23917f508a9 | @Test
public void requestWithState()
{
FeatureResponse pr = new Api500pxStreamBuilder(consumerKey).popularPhotos().resultsPerPage(2).withStates().getResponse();
assertNotNull(pr);
} |
57ba8e33-be2d-4e62-8811-9a51c8292ae9 | @Test
public void requestWithStore()
{
FeatureResponse pr = new Api500pxStreamBuilder(consumerKey).popularPhotos().resultsPerPage(2).withStore().getResponse();
assertNotNull(pr);
} |
ef780015-941b-491f-8443-111641413b26 | @BeforeClass
public static void checkForconsumerKey()
{
consumerKey = ConsumerKeyFinder.getKey();
if (consumerKey.isEmpty())
{
fail("Please define your consumer key");
}
} |
b7d1cd21-6e27-4a2e-a732-15c3f0ac3eb6 | @Test
public void testSimple()
{
PhotoResponse pr = new Api500pxPhotoUrlBuilder(1, consumerKey).largeThumbnail().getResponse();
assertNotNull("No PhotoResponse", pr);
Photo p = pr.getPhoto();
assertNotNull("No photo found", p);
assertEquals(1, p.getId());
} |
77730f48-d5fe-4dcc-84ce-9fd8031914f6 | @Test
public void testNoImage()
{
PhotoResponse pr = new Api500pxPhotoUrlBuilder(101010000, consumerKey).largeThumbnail().getResponse();
assertNotNull("No PhotoResponse", pr);
Photo p = pr.getPhoto();
assertNull("Found a photo where one wasn't expected", p);
} |
92f68f42-b5bc-4439-9a5d-417664cdb8e7 | @Test
// this image had issues decoding (cmyk?)
public void getPhoto355711()
{
int imageId = 355711;
PhotoResponse pr = new Api500pxPhotoUrlBuilder(imageId, consumerKey).smallThumbnail().getResponse();
assertNotNull("No response", pr);
Photo p = pr.getPhoto();
assertNotNull("No photo", p);
assertNotNull("No image url", p.getImageUrl());
BufferedImage image = p.getImage();
assertNotNull("No image", image);
} |
12eff023-bf99-4b7c-8143-4b5990f2f52e | public static <E> List<E> getEmptySimpleList() {
return SimpleList.emptyList();
} |
6dcf29ff-a85e-4afd-8abf-11bc1b8ace50 | public static <E> List<E> getEmptyRandomAccessList() {
return RandomAccessLinkedList.emptyList();
} |
9632ed6f-d63a-45f1-83ab-dfc2c1b548e8 | protected RandomAccessLinkedList() {
this.head = null;
this.index = -1;
this.maxIndex = 0;
this.links = null;
} |
a76b880f-be45-4bc1-9f09-62c6724c6832 | @SuppressWarnings("unchecked")
public RandomAccessLinkedList(E head, RandomAccessLinkedList<E> tail) {
this.head = head;
this.index = tail.length();
maxIndex = calcMaxIndex(index + 1);
links = new RandomAccessLinkedList[maxIndex + 1];
links[0] = tail;
for (int i = 1; i <= maxIndex; i++) {
links[i] = links[i - 1].links[i - 1];
}
} |
b5c7254f-6e0b-4def-b9f3-133dde9ff51e | public static <T> RandomAccessLinkedList<T> emptyList() {
return new RandomAccessLinkedList<T>() {
@Override
public boolean isEmpty() {
return true;
}
@Override
public int length() {
return 0;
}
@Override
public int hashCode() {
return -1;
}
@SuppressWarnings("rawtypes")
@Override
public boolean equals(Object obj) {
if (obj instanceof RandomAccessLinkedList) {
return ((RandomAccessLinkedList) obj).isEmpty();
} else {
return false;
}
}
@Override
public String toString() {
return "[]";
}
};
} |
2ea8e90d-9043-4ea6-bdca-1a41732eee37 | @Override
public boolean isEmpty() {
return true;
} |
a5aed983-176f-439b-b3dc-e052588f62ca | @Override
public int length() {
return 0;
} |
36ffb1a4-0bef-41f2-8923-6716287c9e57 | @Override
public int hashCode() {
return -1;
} |
67765f90-8c41-4976-829a-f42bcaa3accb | @SuppressWarnings("rawtypes")
@Override
public boolean equals(Object obj) {
if (obj instanceof RandomAccessLinkedList) {
return ((RandomAccessLinkedList) obj).isEmpty();
} else {
return false;
}
} |
ae0d6f29-ea53-41b1-a6e9-9286dfe7fd01 | @Override
public String toString() {
return "[]";
} |
1a59e742-4589-48f9-bb8a-0584363c3a0e | @Override
public List<E> add(E item) {
return new RandomAccessLinkedList<E>(item, this);
} |
c71e7fae-24da-499c-bc33-6cdfb7e68f9c | @Override
public Optional<E> get(int target) {
if (this.isEmpty()) {
return Optional.empty();
}
int distance = index - target;
if (distance == 0) {
return Optional.of(head);
} else if (distance < 0) {
return Optional.empty();
} else {
int logDistance = calcLog2(distance);
int jumpIndex = min(maxIndex, logDistance);
return links[jumpIndex].get(target);
}
} |
29c5d936-8ea9-40c7-8678-edeed7f44f2a | @Override
public Iterator<E> iterator() {
Iterator<E> iterator = new Iterator<E>() {
List<E> list = RandomAccessLinkedList.this;
@Override
public E next() {
if (list.isEmpty()) {
throw new NoSuchElementException(
"next() called on empty iterator");
}
E value = list.head().get();
list = list.tail();
return value;
}
@Override
public boolean hasNext() {
return !list.isEmpty();
}
@Override
public void remove() {
throw new UnsupportedOperationException(
"remove invoked on an iterator backed by a readonly object");
}
};
return iterator;
} |
fc7aa5ad-c799-47d0-831b-eacd45b5b134 | @Override
public E next() {
if (list.isEmpty()) {
throw new NoSuchElementException(
"next() called on empty iterator");
}
E value = list.head().get();
list = list.tail();
return value;
} |
ac97c241-de13-499d-9828-172c47c7990d | @Override
public boolean hasNext() {
return !list.isEmpty();
} |
040fe887-6b75-4393-b771-a3c7da1bdeb1 | @Override
public void remove() {
throw new UnsupportedOperationException(
"remove invoked on an iterator backed by a readonly object");
} |
e17dcb03-3547-4d9a-8ef4-0408e42bb6f9 | @Override
public List<E> reverse() {
List<E> l = RandomAccessLinkedList.emptyList();
for (E item : this) {
l = l.add(item);
}
return l;
} |
c84fd63b-bee9-4a83-8f6b-82d3b9f13cb1 | @Override
public <F> List<F> map(Function<E, F> mapper) {
List<E> reversed = this.reverse();
List<F> target = RandomAccessLinkedList.emptyList();
for (E item : reversed) {
target = target.add(mapper.apply(item));
}
return target;
} |
7a6c3e62-e123-43c5-a560-73b848fd9cf7 | @Override
public <F> List<F> flatMap(Function<E, List<F>> flatMapper) {
List<E> reversed = this.reverse();
List<F> target = RandomAccessLinkedList.emptyList();
for (E item : reversed) {
for (F member : flatMapper.apply(item).reverse()) {
target = target.add(member);
}
}
return target;
} |
368d5177-cbf1-4fcd-9e68-cbb2e8afe22b | @Override
public List<E> filter(Function<E, Boolean> selector) {
List<E> reversed = this.reverse();
List<E> target = RandomAccessLinkedList.emptyList();
for (E item : reversed) {
if (selector.apply(item)) {
target = target.add(item);
}
}
return target;
} |
d02e5383-55b0-4385-af95-c9ea5886bb35 | @Override
public Optional<E> head() {
return Optional.of(head);
} |
b6669241-7510-4443-9a07-fe19cdf22916 | @Override
public List<E> tail() {
return links[0];
} |
80aca991-a4fd-4d3b-8806-67e0ec192ae6 | @Override
public boolean isEmpty() {
return false;
} |
e7f7175b-6ab3-4ce7-aebf-d97546b96b09 | @Override
public int length() {
return index + 1;
} |
c9594958-0333-48bc-9b9e-34aaf4f89550 | protected static int calcLog2(int x) {
int i;
for (i = 0; x > 0; i++) {
x = x >>> 1;
}
return i - 1;
} |
4c4611a2-5e6d-4b9e-86c5-73593153b90e | protected static int calcMaxIndex(int index) {
int i;
for (i = 0; (index & 0x0001) == 0; i++) {
index = index >>> 1;
}
return i;
} |
bd851c75-22fc-42e1-b39b-b6929da8e11b | protected static int min(int x, int y) {
return x > y ? y : x;
} |
92a0ec95-1a32-43b7-be77-820d17057a50 | @Override
public String toString() {
return reverse().toString(true);
} |
31c94bf9-e322-4518-a874-bf0991c840e8 | public List<E> add(E item); |
2ab53b7e-ac2c-4b1c-a863-dcca975d3529 | public Optional<E> get(int index); |
5d0b4173-48f9-4cde-baa9-223841392f56 | public <F> List<F> map(Function<E, F> mapper); |
671e1475-f4cd-4a84-ab4a-4557c71bd6a0 | public <F> List<F> flatMap(Function<E, List<F>> flatMapper); |
5984ebb6-2b35-4dd4-a30a-92608700dcb3 | public List<E> filter(Function<E, Boolean> selector); |
045f2a6d-96f5-4559-901e-d7e30e911b60 | public default boolean contains(E item) {
List<E> cur = this;
while (!cur.isEmpty()) {
if (cur.head().get().equals(item)) {
return true;
}
cur = cur.tail();
}
return false;
} |
19c468a4-f6df-4fd3-b16f-ccfa58adce38 | public default boolean contains(Function<E, Boolean> selector) {
List<E> cur = this;
while (!cur.isEmpty()) {
if (cur.head().map(selector).get()) {
return true;
}
cur = cur.tail();
}
return false;
} |
95347126-4fbd-4040-99b3-224cd33837b9 | public Optional<E> head(); |
654d4bae-26d9-4ff0-9a9e-a8bec12ebca2 | public List<E> tail(); |
4f4a7c6e-6f4b-4cd6-b3cb-1464762a0b25 | public boolean isEmpty(); |
4eb679e7-8f28-447d-8128-3449a0f12570 | public int length(); |
d48d2af7-b46d-475a-9c3e-c123fa10b8ad | List<E> reverse(); |
4bcdf525-00d2-450d-8c87-4a6d6848074a | public default String toString(boolean isOuter) {
String headString;
String tailString;
if (isOuter) {
headString = "[";
tailString = "]";
} else {
headString = "";
tailString = "";
}
return headString
+ ((tail().isEmpty()) ? head().toString() : head().toString()
+ ", " + tail().toString(false)) + tailString;
} |
4641d45f-7fb0-4a7c-96b8-dc0b8413b483 | protected SimpleList() {
head = null;
tail = null;
index = -1;
} |
68b5dff0-95f4-4067-b0b1-bb37c8f08d08 | @Override
public List<E> add(E item) {
return new SimpleList<E>(item, this);
} |
f9898ecd-36d1-4e2a-a345-80f115551981 | public SimpleList(E head, List<E> tail) {
this.head = head;
this.tail = tail;
this.index = tail.length();
} |
9c666b89-0e23-4015-ae3c-ae7fdf63fe93 | @Override
public Optional<E> get(int index) {
List<E> cur = this;
while (!cur.isEmpty()) {
if (cur.tail().length() == index) {
return cur.head();
}
cur = cur.tail();
}
return Optional.empty();
} |
02f49e59-62c1-4d61-9308-9e36ef6025f9 | @Override
public Iterator<E> iterator() {
Iterator<E> iterator = new Iterator<E>() {
List<E> list = SimpleList.this;
@Override
public E next() {
if (list.isEmpty()) {
throw new NoSuchElementException(
"next() called on empty iterator");
}
E value = list.head().get();
list = list.tail();
return value;
}
@Override
public boolean hasNext() {
return !list.isEmpty();
}
@Override
public void remove() {
throw new UnsupportedOperationException(
"remove invoked on an iterator backed by a readonly object");
}
};
return iterator;
} |
7ef303d7-df5c-4a42-a052-58c88ee40dcd | @Override
public E next() {
if (list.isEmpty()) {
throw new NoSuchElementException(
"next() called on empty iterator");
}
E value = list.head().get();
list = list.tail();
return value;
} |
0cc5ecf9-bd11-45a5-a302-ab002caec2e7 | @Override
public boolean hasNext() {
return !list.isEmpty();
} |
bcf9ec7e-33ad-47ec-ab4c-679ba3a14ff2 | @Override
public void remove() {
throw new UnsupportedOperationException(
"remove invoked on an iterator backed by a readonly object");
} |
857824dd-52c1-4806-ac9b-94c005576a91 | @Override
public List<E> reverse() {
List<E> l = SimpleList.emptyList();
for (E item : this) {
l = l.add(item);
}
return l;
} |
fc24db2d-6428-4876-99f1-5ad9a45c5e2f | @Override
public <F> List<F> map(Function<E, F> mapper) {
List<E> reversed = this.reverse();
List<F> target = SimpleList.emptyList();
for (E item : reversed) {
target = target.add(mapper.apply(item));
}
return target;
} |
ea79bd4b-d3a5-4a32-a06a-dd6fdb3b5d26 | @Override
public <F> List<F> flatMap(Function<E, List<F>> flatMapper) {
List<E> reversed = this.reverse();
List<F> target = SimpleList.emptyList();
for (E item : reversed) {
for (F member : flatMapper.apply(item).reverse()) {
target = target.add(member);
}
}
return target;
} |
c264dd4c-de88-4303-bb31-d13622b4c9bb | @Override
public List<E> filter(Function<E, Boolean> selector) {
List<E> reversed = this.reverse();
List<E> target = SimpleList.emptyList();
for (E item : reversed) {
if (selector.apply(item)) {
target = target.add(item);
}
}
return target;
} |
91e67f9c-f117-4917-81a5-d4c8d0a0b0e9 | @Override
public Optional<E> head() {
return Optional.of(head);
} |
184dd720-4b77-4264-9d5d-f2ee7e8cfa70 | @Override
public List<E> tail() {
return tail;
} |
8cb4f813-7e90-4d5c-8a10-7dd60c05194b | @Override
public boolean isEmpty() {
return false;
} |
04b0c60b-b976-47a4-aac9-276ac47f5f84 | @Override
public int length() {
return index + 1;
} |
fe2bff84-c4ab-4e34-87df-9ceb0dc57c67 | public static <T> SimpleList<T> emptyList() {
return new SimpleList<T>() {
@Override
public boolean isEmpty() {
return true;
}
@Override
public int length() {
return 0;
}
@Override
public int hashCode() {
return -1;
}
@SuppressWarnings("rawtypes")
@Override
public boolean equals(Object obj) {
if (obj instanceof SimpleList) {
return ((SimpleList) obj).isEmpty();
} else {
return false;
}
}
@Override
public String toString() {
return "[]";
}
};
} |
a0d68918-0654-4141-9cd1-4d2a8f84e276 | @Override
public boolean isEmpty() {
return true;
} |
f1bb00cd-017d-4dd8-8856-a51f70ca44ac | @Override
public int length() {
return 0;
} |
a794ecdb-4109-4a2e-b00d-7f8102a35707 | @Override
public int hashCode() {
return -1;
} |
ecf5daa7-dfbb-4d14-9e6c-1555ffbae3d0 | @SuppressWarnings("rawtypes")
@Override
public boolean equals(Object obj) {
if (obj instanceof SimpleList) {
return ((SimpleList) obj).isEmpty();
} else {
return false;
}
} |
bc8809fd-0fa8-45fa-a15d-e07e7858e108 | @Override
public String toString() {
return "[]";
} |
7ee9faf1-47e7-4626-aaa7-5bc81847f3e2 | @Override
public String toString() {
return reverse().toString(true);
} |
bae8c815-37e4-492a-80f7-99bf71cb275f | public MapperList(List<E> containedList, Function<E, F> mapper) {
super();
this.containedList = containedList;
this.mapper = mapper;
} |
f90fd9e7-c70a-44b3-979d-84e6dffb3442 | @Override
public List<F> add(F item) {
return new SimpleList<F>(item, this);
} |
0e028a20-c36e-4441-9e8e-1745ecee7ae0 | @Override
public Optional<F> get(int index) {
return containedList.get(index).map(mapper);
} |
ac3b125a-3d50-4e36-9ba5-7efe7c3f3388 | @Override
public <G> List<G> map(Function<F, G> mapper) {
return new MapperList<F, G>(this, mapper);
} |
126641a7-6527-45d0-a1f9-b4f81c632876 | @Override
public <G> List<G> flatMap(Function<F, List<G>> flatMapper) {
return new FlatMapperList<F, G>(this, flatMapper);
} |
4cc392d5-1af0-4ff4-9779-edd331499a04 | @Override
public List<F> filter(Function<F, Boolean> selector) {
return new FiltererList<F>(this, selector);
} |
ee9873e6-7f50-48b8-9135-142ead3186e9 | @Override
public boolean contains(F item) {
if (containedList.isEmpty()) {
return false;
} else if (containedList.head().map(mapper)
.equals(Optional.ofNullable(item))) {
return true;
} else {
return tail().contains(item);
}
} |
cded0829-38d9-4c95-8be1-e554a19f854e | @Override
public boolean contains(Function<F, Boolean> selector) {
if (containedList.isEmpty()) {
return false;
} else if (containedList.head().map(mapper).map(selector).get()) {
return true;
} else {
return tail().contains(selector);
}
} |
f7352726-ddbb-4b78-b093-5e9caa3ab6eb | @Override
public Optional<F> head() {
return containedList.head().map(mapper);
} |
79d6db56-ec33-401f-a2b3-6950f50ad566 | @Override
public List<F> tail() {
return containedList.tail().map(mapper);
} |
87d3bb18-7a35-4a12-b52f-2fc1ffc97500 | @Override
public boolean isEmpty() {
return containedList.isEmpty();
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.