dev.robocode.tankroyale.botapi.mapper.BulletStateMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of robocode-tankroyale-bot-api Show documentation
Show all versions of robocode-tankroyale-bot-api Show documentation
Robocode Tank Royale Bot API for Java
package dev.robocode.tankroyale.botapi.mapper;
import dev.robocode.tankroyale.botapi.BulletState;
import dev.robocode.tankroyale.botapi.Color;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
/**
* Utility class for mapping a bot state.
*/
public final class BulletStateMapper {
// Hide constructor to prevent instantiation
private BulletStateMapper() {
}
public static BulletState map(final dev.robocode.tankroyale.schema.BulletState source) {
return new BulletState(
source.getBulletId(),
source.getOwnerId(),
source.getPower(),
source.getX(),
source.getY(),
source.getDirection(),
Color.fromString(source.getColor()));
}
public static Set map(final Collection source) {
Set bulletStates = new HashSet<>();
source.forEach(bulletState -> bulletStates.add(map(bulletState)));
return bulletStates;
}
}