Skip to content

Commit

Permalink
use list instead of set.
Browse files Browse the repository at this point in the history
  • Loading branch information
portlek committed Jul 16, 2024
1 parent 986940d commit 153aca5
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private Collection<FileResource> simplify(final FileResource resource) {
.flatMap(Collection::stream)
.collect(Collectors.toSet());
} else {
return Collections.singleton(resource);
return Collections.singletonList(resource);
}
}
}
8 changes: 4 additions & 4 deletions common/src/main/java/net/infumia/pack/GlyphImageImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
import java.util.List;
import javax.imageio.ImageIO;
import net.infumia.pack.exception.ResourceAlreadyProducedException;
import net.infumia.pack.exception.ResourceNotProducedException;
Expand All @@ -22,7 +22,7 @@ final class GlyphImageImpl implements GlyphImage {
private final TextureProperties properties;

private Character character;
private Set<FontProvider> fontProviders;
private List<FontProvider> fontProviders;

private int width = -1;

Expand Down Expand Up @@ -55,7 +55,7 @@ public void produce(final ArbitraryCharacterFactory characterFactory)
fontProviderBuilder.file(this.texture.key());
fontProviderBuilder.ascent(this.properties.ascent());
fontProviderBuilder.height(this.properties.height());
this.fontProviders = Collections.singleton(fontProviderBuilder.build());
this.fontProviders = Collections.singletonList(fontProviderBuilder.build());
}

@Override
Expand All @@ -68,7 +68,7 @@ public Collection<FontProvider> fontProviders() throws ResourceNotProducedExcept

@Override
public Collection<Texture> textures() throws ResourceNotProducedException {
return Collections.singleton(this.texture);
return Collections.singletonList(this.texture);
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions common/src/main/java/net/infumia/pack/PackDefault.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package net.infumia.pack;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

final class PackDefault implements Pack {

private final FileResourceCompiler compiler;
private final FileResourceMerger merger;
private final Map<String, ResourceProducer> raw = new HashMap<>();
private final Map<String, ResourceProducer> compiled = new HashMap<>();
private final Set<FileResource> resources = new HashSet<>();
private final List<FileResource> resources = new ArrayList<>();

PackDefault(final FileResourceCompiler compiler, final FileResourceMerger merger) {
this.compiler = compiler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void produce(final ArbitraryCharacterFactory characterFactory) {
length * (-1)
);
}
this.fontProviders = Collections.singleton(fontProviderBuilder.build());
this.fontProviders = Collections.singletonList(fontProviderBuilder.build());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.imageio.ImageIO;
import net.infumia.pack.exception.ResourceAlreadyProducedException;
import net.infumia.pack.exception.ResourceNotProducedException;
Expand All @@ -29,7 +28,7 @@ final class ResourceProducerImageMulticharImpl implements ResourceProducerImageM
private final TextureProperties properties;
private final List<String> charactersMapping;

private Set<FontProvider> fontProviders;
private List<FontProvider> fontProviders;
private BufferedImage image;

ResourceProducerImageMulticharImpl(
Expand Down Expand Up @@ -76,7 +75,7 @@ public void produce(final ArbitraryCharacterFactory characterFactory)
mappingLines.add(builder.toString());
}
fontProviderBuilder.characters(mappingLines);
this.fontProviders = Collections.singleton(fontProviderBuilder.build());
this.fontProviders = Collections.singletonList(fontProviderBuilder.build());
}

@Override
Expand All @@ -86,7 +85,7 @@ public Collection<FontProvider> fontProviders() throws ResourceNotProducedExcept

@Override
public Collection<Texture> textures() throws ResourceNotProducedException {
return Collections.singleton(this.texture);
return Collections.singletonList(this.texture);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package net.infumia.pack;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import net.infumia.pack.exception.ResourceAlreadyProducedException;
Expand All @@ -23,7 +22,7 @@ final class ResourceProducerLanguageImpl implements ResourceProducerLanguage {
private final Texture texture;
private final Map<TextureProperties, ResourceProducerImageMultichar> propertiesToMultichar;

private Set<FontProvider> fontProviders;
private List<FontProvider> fontProviders;

ResourceProducerLanguageImpl(
final Key key,
Expand Down Expand Up @@ -60,7 +59,7 @@ public void produce(final ArbitraryCharacterFactory characterFactory)
if (this.fontProviders != null) {
throw new ResourceAlreadyProducedException();
}
this.fontProviders = new HashSet<>();
this.fontProviders = new ArrayList<>();
this.propertiesToMultichar.values()
.forEach(multichar -> {
multichar.produce(characterFactory);
Expand All @@ -75,7 +74,7 @@ public Collection<FontProvider> fontProviders() throws ResourceNotProducedExcept

@Override
public Collection<Texture> textures() throws ResourceNotProducedException {
return Collections.singleton(this.texture);
return Collections.singletonList(this.texture);
}

private ResourceProducerImageMultichar getGlyphCollection(final int height, final int ascent) {
Expand Down

0 comments on commit 153aca5

Please sign in to comment.