add /apis.json and (re)add .../versions.json paths

This commit is contained in:
2023-04-04 15:45:51 -05:00
parent e779c392bb
commit 74cd0e0a57
4 changed files with 133 additions and 4 deletions

View File

@ -29,9 +29,60 @@ import java.util.List;
/*******************************************************************************
** List.of is "great", but annoying because it makes unmodifiable lists...
** So, replace it with this, which returns ArrayLists, which "don't suck"
**
** Can use it 3 ways:
** ListBuilder.of(value, value2, ...) => List (an ArrayList)
** ListBuilder.<ElementType>of(SomeList::new).with(value).with(value2)...build() => SomeList (the type you specify)
** new ListBuilder.<ElementType>.with(value).with(value2)...build() => List (an ArrayList - for when you have more than 10 values...)
*******************************************************************************/
public class ListBuilder
public class ListBuilder<E>
{
private List<E> list;
/*******************************************************************************
** Constructor
**
*******************************************************************************/
public ListBuilder()
{
this.list = new ArrayList<>();
}
/*******************************************************************************
** Constructor
**
*******************************************************************************/
public ListBuilder(List<E> list)
{
this.list = list;
}
/*******************************************************************************
**
*******************************************************************************/
public ListBuilder<E> with(E value)
{
list.add(value);
return (this);
}
/*******************************************************************************
**
*******************************************************************************/
public List<E> build()
{
return (this.list);
}
/*******************************************************************************
**

View File

@ -22,6 +22,8 @@
package com.kingsrook.qqq.backend.core.utils.collections;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ -69,4 +71,22 @@ class ListBuilderTest
///////////////////////////////////////
list.add(4);
}
/*******************************************************************************
**
*******************************************************************************/
@Test
void testBuilderMode()
{
List<String> builtList = new ListBuilder<String>().with("A").with("B").build();
assertEquals(List.of("A", "B"), builtList);
assertEquals(ArrayList.class, builtList.getClass());
List<String> builtLinkedList = new ListBuilder<String>(new LinkedList<>()).with("A").with("B").build();
assertEquals(List.of("A", "B"), builtLinkedList);
assertEquals(LinkedList.class, builtLinkedList.getClass());
}
}