GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Supplied more items operation methods · javandcpp/MultiType@f7469d6

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • library/src
    • main/java/me/drakeet/multitype
      • Items.java
      • TypeItem.java
    • test/java/me/drakeet/multitype
      • ItemsTest.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎library/src/main/java/me/drakeet/multitype/Items.java‎

Copy file name to clipboardExpand all lines: library/src/main/java/me/drakeet/multitype/Items.java
+49-4Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,57 @@ public Items(@NonNull final List<TypeItem> items) {
4040
}
4141

4242

43-
public void add(@NonNull final ItemContent content) {
44-
items.add(factory.newItem(content));
43+
@NonNull public List<? extends TypeItem> toList() {
44+
return items;
4545
}
4646

4747

48-
@NonNull public List<? extends TypeItem> toList() {
49-
return items;
48+
public boolean add(@NonNull final ItemContent content) {
49+
return items.add(factory.newItem(content));
50+
}
51+
52+
53+
public void add(int index, @NonNull ItemContent content) {
54+
items.add(index, factory.newItem(content));
55+
}
56+
57+
58+
@NonNull public TypeItem get(int index) {
59+
return items.get(index);
60+
}
61+
62+
63+
public TypeItem set(int index, @NonNull ItemContent content) {
64+
return items.set(index, factory.newItem(content));
65+
}
66+
67+
68+
public boolean contains(@NonNull final ItemContent content) {
69+
return items.contains(factory.newItem(content));
70+
}
71+
72+
73+
@NonNull public TypeItem remove(int index) {
74+
return items.remove(index);
75+
}
76+
77+
78+
public boolean remove(@NonNull final ItemContent content) {
79+
return items.remove(factory.newItem(content));
80+
}
81+
82+
83+
public int size() {
84+
return items.size();
85+
}
86+
87+
88+
public boolean isEmpty() {
89+
return items.isEmpty();
90+
}
91+
92+
93+
public void clear() {
94+
items.clear();
5095
}
5196
}
Collapse file

‎library/src/main/java/me/drakeet/multitype/TypeItem.java‎

Copy file name to clipboardExpand all lines: library/src/main/java/me/drakeet/multitype/TypeItem.java
+19-2Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424
*/
2525
public class TypeItem {
2626

27-
@NonNull public ItemContent content;
27+
public ItemContent content;
2828
@Nullable public String extra;
2929

3030

3131
public TypeItem() {
3232
}
3333

3434

35-
public TypeItem(@NonNull ItemContent content, String extra) {
35+
public TypeItem(@NonNull ItemContent content, @Nullable String extra) {
3636
this.extra = extra;
3737
this.content = content;
3838
}
@@ -44,4 +44,21 @@ public TypeItem(@NonNull ItemContent content, String extra) {
4444
", extra='" + extra + '\'' +
4545
'}';
4646
}
47+
48+
49+
@Override public boolean equals(Object o) {
50+
if (this == o) return true;
51+
if (o == null || getClass() != o.getClass()) return false;
52+
TypeItem typeItem = (TypeItem) o;
53+
if (!content.equals(typeItem.content)) return false;
54+
return extra != null ? extra.equals(typeItem.extra) : typeItem.extra == null;
55+
56+
}
57+
58+
59+
@Override public int hashCode() {
60+
int result = content.hashCode();
61+
result = 31 * result + (extra != null ? extra.hashCode() : 0);
62+
return result;
63+
}
4764
}
Collapse file

‎library/src/test/java/me/drakeet/multitype/ItemsTest.java‎

Copy file name to clipboard
+98Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/*
2+
* Copyright 2016 drakeet. https://github.com/drakeet
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package me.drakeet.multitype;
18+
19+
import org.junit.Before;
20+
import org.junit.Test;
21+
22+
/**
23+
* @author drakeet
24+
*/
25+
public class ItemsTest {
26+
27+
@Before
28+
public void setUp() throws Exception {
29+
30+
}
31+
32+
33+
@Test
34+
public void toList() throws Exception {
35+
36+
}
37+
38+
39+
@Test
40+
public void add() throws Exception {
41+
42+
}
43+
44+
45+
@Test
46+
public void add1() throws Exception {
47+
48+
}
49+
50+
51+
@Test
52+
public void get() throws Exception {
53+
54+
}
55+
56+
57+
@Test
58+
public void set() throws Exception {
59+
60+
}
61+
62+
63+
@Test
64+
public void contains() throws Exception {
65+
66+
}
67+
68+
69+
@Test
70+
public void remove() throws Exception {
71+
72+
}
73+
74+
75+
@Test
76+
public void remove1() throws Exception {
77+
78+
}
79+
80+
81+
@Test
82+
public void size() throws Exception {
83+
84+
}
85+
86+
87+
@Test
88+
public void isEmpty() throws Exception {
89+
90+
}
91+
92+
93+
@Test
94+
public void clear() throws Exception {
95+
96+
}
97+
98+
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.