Skip to content

Commit 752cb5a

Browse files
committed
added README and LICENSE
1 parent 33a0013 commit 752cb5a

2 files changed

Lines changed: 128 additions & 0 deletions

File tree

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Robin Panicker
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# ax-tuple-java
2+
3+
A simple, lightweight, and immutable Tuple implementation for Java projects.
4+
5+
## Overview
6+
7+
`ax-tuple-java` provides two main classes to manage collections of data without the need for custom DTOs or POJOs for every small data structure:
8+
9+
1. **Tuple**: An ordered collection of elements.
10+
2. **NamedTuple**: A collection of elements associated with unique string keys.
11+
12+
Both implementations are designed to be immutable and provide type-safe access through generic methods.
13+
14+
## Installation
15+
16+
Add the following dependency to your `pom.xml`:
17+
18+
```xml
19+
<dependency>
20+
<groupId>com.appxiom.ax.tuple</groupId>
21+
<artifactId>ax-tuple</artifactId>
22+
<version>0.1.1</version>
23+
</dependency>
24+
```
25+
26+
## Usage
27+
28+
### Using `Tuple`
29+
30+
Create a tuple with `Tuple.of()`:
31+
32+
```java
33+
import com.appxiom.ax.tuple.Tuple;
34+
35+
Tuple tuple = Tuple.of("Hello", 42, 3.14);
36+
37+
// Access by index
38+
String s = tuple.get(0); // Inferred type
39+
Integer i = tuple.get(1, Integer.class); // Explicit type
40+
Object o = tuple.getObject(2);
41+
42+
System.out.println("Size: " + tuple.size()); // Size: 3
43+
```
44+
45+
### Using `NamedTuple`
46+
47+
Create a named tuple from a `Map`:
48+
49+
```java
50+
import com.appxiom.ax.tuple.NamedTuple;
51+
import java.util.Map;
52+
53+
NamedTuple user = NamedTuple.of(Map.of(
54+
"id", 1,
55+
"username", "robin",
56+
"active", true
57+
));
58+
59+
// Access by key
60+
String username = user.get("username");
61+
Boolean isActive = user.get("active", Boolean.class);
62+
63+
System.out.println(user.toString());
64+
```
65+
66+
## Using as HashMap Keys
67+
68+
Both `Tuple` and `NamedTuple` override `equals()` and `hashCode()`, making them perfectly suitable for use as keys in a `HashMap` or as elements in a `HashSet`.
69+
70+
Two tuples are considered equal if they contain the same elements in the same order. Two named tuples are equal if they contain the same key-value pairs.
71+
72+
```java
73+
import java.util.HashMap;
74+
import com.appxiom.ax.tuple.Tuple;
75+
76+
HashMap<Tuple, String> cache = new HashMap<>();
77+
Tuple key = Tuple.of("request", 12345);
78+
79+
cache.put(key, "Cached Result");
80+
81+
// Retrievable with a different Tuple instance containing identical data
82+
System.out.println(cache.get(Tuple.of("request", 12345))); // Output: Cached Result
83+
```
84+
85+
## License
86+
87+
MIT License
88+
89+
Copyright (c) 2026 Robin Panicker
90+
91+
Permission is hereby granted, free of charge, to any person obtaining a copy
92+
of this software and associated documentation files (the "Software"), to deal
93+
in the Software without restriction, including without limitation the rights
94+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
95+
copies of the Software, and to permit persons to whom the Software is
96+
furnished to do so, subject to the following conditions:
97+
98+
The above copyright notice and this permission notice shall be included in all
99+
copies or substantial portions of the Software.
100+
101+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
102+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
103+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
104+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
105+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
106+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
107+
SOFTWARE.

0 commit comments

Comments
 (0)