Renamed ReusableServerContext to DefaultServerContext
This commit is contained in:
parent
15f741bc04
commit
0f909039fe
@ -44,14 +44,14 @@ import ru.windcorp.progressia.server.world.context.*;
|
|||||||
* Use wrappers to alter these properties.
|
* Use wrappers to alter these properties.
|
||||||
* <p>
|
* <p>
|
||||||
* This class defines the outward-facing safe interface of the actual
|
* This class defines the outward-facing safe interface of the actual
|
||||||
* implementation located in {@link ReusableServerContextImpl}. The reasoning
|
* implementation located in {@link DefaultServerContextImpl}. The reasoning
|
||||||
* for creating a subclass is to allow a single instance to implement both
|
* for creating a subclass is to allow a single instance to implement both
|
||||||
* {@linkplain ReusableServerContextBuilders builder interfaces} and the context
|
* {@linkplain DefaultServerContextBuilders builder interfaces} and the context
|
||||||
* interface without causing confusion around object states.
|
* interface without causing confusion around object states.
|
||||||
*
|
*
|
||||||
* @author javapony
|
* @author javapony
|
||||||
*/
|
*/
|
||||||
public abstract class ReusableServerContext extends AbstractContextRO<BlockData, TileData, EntityData>
|
public abstract class DefaultServerContext extends AbstractContextRO<BlockData, TileData, EntityData>
|
||||||
implements ServerTileContext {
|
implements ServerTileContext {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -87,9 +87,9 @@ public abstract class ReusableServerContext extends AbstractContextRO<BlockData,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Do not extend ReusableServerContext directly. Use
|
* Do not extend ReusableServerContext directly. Use
|
||||||
* {@link ReusableServerContextImpl} if this is truly necessary.
|
* {@link DefaultServerContextImpl} if this is truly necessary.
|
||||||
*/
|
*/
|
||||||
ReusableServerContext() {
|
DefaultServerContext() {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,11 +97,11 @@ public abstract class ReusableServerContext extends AbstractContextRO<BlockData,
|
|||||||
* Resets this object to its uninitialized state and returns a builder to
|
* Resets this object to its uninitialized state and returns a builder to
|
||||||
* reinitialize it.
|
* reinitialize it.
|
||||||
*
|
*
|
||||||
* @return a {@link ReusableServerContextBuilders.Empty} instance that may
|
* @return a {@link DefaultServerContextBuilders.Empty} instance that may
|
||||||
* be used to reinitialize this object
|
* be used to reinitialize this object
|
||||||
* @throws IllegalStateException if active subcontexting is detected
|
* @throws IllegalStateException if active subcontexting is detected
|
||||||
*/
|
*/
|
||||||
public abstract ReusableServerContextBuilders.Empty reuse() throws IllegalStateException;
|
public abstract DefaultServerContextBuilders.Empty reuse() throws IllegalStateException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the {@link Role} currently assumed by this object.
|
* Returns the {@link Role} currently assumed by this object.
|
||||||
@ -111,30 +111,30 @@ public abstract class ReusableServerContext extends AbstractContextRO<BlockData,
|
|||||||
public abstract Role getRole();
|
public abstract Role getRole();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new {@link ReusableServerContext} using an appropriate
|
* Instantiates a new {@link DefaultServerContext} using an appropriate
|
||||||
* implementation.
|
* implementation.
|
||||||
*
|
*
|
||||||
* @return a {@link ReusableServerContextBuilders.Empty} instance that can
|
* @return a {@link DefaultServerContextBuilders.Empty} instance that can
|
||||||
* be used to initialize this object
|
* be used to initialize this object
|
||||||
*/
|
*/
|
||||||
public static ReusableServerContextBuilders.Empty empty() {
|
public static DefaultServerContextBuilders.Empty empty() {
|
||||||
return new ReusableServerContextImpl();
|
return new DefaultServerContextImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReusableServerContext push(Vec3i location) {
|
public DefaultServerContext push(Vec3i location) {
|
||||||
super.push(location);
|
super.push(location);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReusableServerContext push(Vec3i location, RelFace face) {
|
public DefaultServerContext push(Vec3i location, RelFace face) {
|
||||||
super.push(location, face);
|
super.push(location, face);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReusableServerContext push(Vec3i location, RelFace face, int layer) {
|
public DefaultServerContext push(Vec3i location, RelFace face, int layer) {
|
||||||
super.push(location, face, layer);
|
super.push(location, face, layer);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
@ -25,9 +25,9 @@ import ru.windcorp.progressia.common.world.rels.RelFace;
|
|||||||
import ru.windcorp.progressia.server.Server;
|
import ru.windcorp.progressia.server.Server;
|
||||||
import ru.windcorp.progressia.server.world.WorldLogic;
|
import ru.windcorp.progressia.server.world.WorldLogic;
|
||||||
|
|
||||||
public interface ReusableServerContextBuilders {
|
public interface DefaultServerContextBuilders {
|
||||||
|
|
||||||
ReusableServerContext build();
|
DefaultServerContext build();
|
||||||
|
|
||||||
public interface Empty /* does not extend RSCB */ {
|
public interface Empty /* does not extend RSCB */ {
|
||||||
|
|
||||||
@ -39,11 +39,11 @@ public interface ReusableServerContextBuilders {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface WithWorld extends ReusableServerContextBuilders {
|
public interface WithWorld extends DefaultServerContextBuilders {
|
||||||
|
|
||||||
WithLocation at(Vec3i location);
|
WithLocation at(Vec3i location);
|
||||||
|
|
||||||
default ReusableServerContext at(TileGenericReferenceRO<?, ?, ?, ?, ?> reference) {
|
default DefaultServerContext at(TileGenericReferenceRO<?, ?, ?, ?, ?> reference) {
|
||||||
if (!reference.isValid()) {
|
if (!reference.isValid()) {
|
||||||
throw new IllegalArgumentException("Reference " + reference + " is invalid");
|
throw new IllegalArgumentException("Reference " + reference + " is invalid");
|
||||||
}
|
}
|
||||||
@ -54,12 +54,12 @@ public interface ReusableServerContextBuilders {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface WithLocation extends ReusableServerContextBuilders {
|
public interface WithLocation extends DefaultServerContextBuilders {
|
||||||
|
|
||||||
WithTileStack on(RelFace side);
|
WithTileStack on(RelFace side);
|
||||||
WithTileStack on(BlockFace side);
|
WithTileStack on(BlockFace side);
|
||||||
|
|
||||||
default ReusableServerContext on(TileGenericReferenceRO<?, ?, ?, ?, ?> reference) {
|
default DefaultServerContext on(TileGenericReferenceRO<?, ?, ?, ?, ?> reference) {
|
||||||
if (!reference.isValid()) {
|
if (!reference.isValid()) {
|
||||||
throw new IllegalArgumentException("Reference " + reference + " is invalid");
|
throw new IllegalArgumentException("Reference " + reference + " is invalid");
|
||||||
}
|
}
|
||||||
@ -70,11 +70,11 @@ public interface ReusableServerContextBuilders {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface WithTileStack extends ReusableServerContextBuilders {
|
public interface WithTileStack extends DefaultServerContextBuilders {
|
||||||
|
|
||||||
ReusableServerContext index(int index);
|
DefaultServerContext index(int index);
|
||||||
|
|
||||||
default ReusableServerContext index(TileGenericReferenceRO<?, ?, ?, ?, ?> reference) {
|
default DefaultServerContext index(TileGenericReferenceRO<?, ?, ?, ?, ?> reference) {
|
||||||
if (!reference.isValid()) {
|
if (!reference.isValid()) {
|
||||||
throw new IllegalArgumentException("Reference " + reference + " is invalid");
|
throw new IllegalArgumentException("Reference " + reference + " is invalid");
|
||||||
}
|
}
|
@ -39,15 +39,15 @@ import ru.windcorp.progressia.server.world.block.BlockLogic;
|
|||||||
import ru.windcorp.progressia.server.world.context.ServerTileContext;
|
import ru.windcorp.progressia.server.world.context.ServerTileContext;
|
||||||
import ru.windcorp.progressia.server.world.tile.TileLogic;
|
import ru.windcorp.progressia.server.world.tile.TileLogic;
|
||||||
|
|
||||||
class ReusableServerContextImpl extends ReusableServerContext
|
class DefaultServerContextImpl extends DefaultServerContext
|
||||||
implements ReusableServerContextBuilders.Empty, ReusableServerContextBuilders.WithWorld,
|
implements DefaultServerContextBuilders.Empty, DefaultServerContextBuilders.WithWorld,
|
||||||
ReusableServerContextBuilders.WithLocation, ReusableServerContextBuilders.WithTileStack {
|
DefaultServerContextBuilders.WithLocation, DefaultServerContextBuilders.WithTileStack {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* STATE MANAGEMENT & UTIL
|
* STATE MANAGEMENT & UTIL
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public ReusableServerContextImpl() {
|
public DefaultServerContextImpl() {
|
||||||
reuse();
|
reuse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ class ReusableServerContextImpl extends ReusableServerContext
|
|||||||
/**
|
/**
|
||||||
* The Logic view returned by {@link #logic()}.
|
* The Logic view returned by {@link #logic()}.
|
||||||
*/
|
*/
|
||||||
protected final ReusableServerContextImpl.Logic logic = new Logic();
|
protected final DefaultServerContextImpl.Logic logic = new Logic();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Role currently assumed by this object.
|
* Returns the Role currently assumed by this object.
|
||||||
@ -217,7 +217,7 @@ class ReusableServerContextImpl extends ReusableServerContext
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReusableServerContext build() {
|
public DefaultServerContext build() {
|
||||||
assert requireBuilderRole(null);
|
assert requireBuilderRole(null);
|
||||||
isBuilder = false;
|
isBuilder = false;
|
||||||
return this;
|
return this;
|
||||||
@ -270,7 +270,7 @@ class ReusableServerContextImpl extends ReusableServerContext
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReusableServerContext index(int index) {
|
public DefaultServerContext index(int index) {
|
||||||
requireBuilderRole(Role.TILE_STACK);
|
requireBuilderRole(Role.TILE_STACK);
|
||||||
frame.layer = index;
|
frame.layer = index;
|
||||||
return build();
|
return build();
|
||||||
@ -538,7 +538,7 @@ class ReusableServerContextImpl extends ReusableServerContext
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isTagValid(Vec3i location, BlockFace face, int tag) {
|
public boolean isTagValid(Vec3i location, BlockFace face, int tag) {
|
||||||
return ReusableServerContextImpl.this.isTagValid(location, face, tag);
|
return DefaultServerContextImpl.this.isTagValid(location, face, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -573,7 +573,7 @@ class ReusableServerContextImpl extends ReusableServerContext
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTag() {
|
public int getTag() {
|
||||||
return ReusableServerContextImpl.this.getTag();
|
return DefaultServerContextImpl.this.getTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -592,25 +592,25 @@ class ReusableServerContextImpl extends ReusableServerContext
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Logic push(Vec3i location) {
|
public Logic push(Vec3i location) {
|
||||||
ReusableServerContextImpl.this.push(location);
|
DefaultServerContextImpl.this.push(location);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Logic push(Vec3i location, RelFace face) {
|
public Logic push(Vec3i location, RelFace face) {
|
||||||
ReusableServerContextImpl.this.push(location, face);
|
DefaultServerContextImpl.this.push(location, face);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Logic push(Vec3i location, RelFace face, int layer) {
|
public Logic push(Vec3i location, RelFace face, int layer) {
|
||||||
ReusableServerContextImpl.this.push(location, face, layer);
|
DefaultServerContextImpl.this.push(location, face, layer);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void pop() {
|
public void pop() {
|
||||||
ReusableServerContextImpl.this.pop();
|
DefaultServerContextImpl.this.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -618,13 +618,13 @@ class ReusableServerContextImpl extends ReusableServerContext
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReusableServerContext data() {
|
public DefaultServerContext data() {
|
||||||
return ReusableServerContextImpl.this;
|
return DefaultServerContextImpl.this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return ReusableServerContextImpl.this + ".Logic";
|
return DefaultServerContextImpl.this + ".Logic";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue
Block a user