@Test public void testMergeSyncSiteswapsFailOnInvalidSiteswap() { Siteswap s1 = new Siteswap("86277"); Siteswap s2 = new Siteswap("6787a"); Siteswap merged = Siteswap.mergeCompatible(s1, s2); assertEquals(merged, null); }
public static Siteswap mergeCompatible(Siteswap s1, Siteswap s2) { Siteswap i1 = s1.toInterface().toPattern(); Siteswap i2 = s2.toInterface().toPattern(); if (!s2.rotateToInterface(i1)) { return null; } int length = 2 * s1.period_length(); Siteswap mergedSiteswap = new Siteswap(new byte[length]); mergedSiteswap.setSynchronousStartPosition(s1.getSynchronousStartPosition()); mergedSiteswap.setNumberOfSynchronousHands(s1.getNumberOfSynchronousHands()); mergedSiteswap.setNumberOfJugglers(s1.getNumberOfJugglers()); for (int i = 0; i < s1.period_length(); ++i) { mergedSiteswap.set(2*i, s1.at(2*i)); mergedSiteswap.set(2*i+1, s2.at(2*i+1)); } if (!mergedSiteswap.isValid()) { return null; } return mergedSiteswap; }
Siteswap implements Comparable<Siteswap>, Iterable<Byte>, Serializable { public static Siteswap mergeCompatible(Siteswap s1, Siteswap s2) { Siteswap i1 = s1.toInterface().toPattern(); Siteswap i2 = s2.toInterface().toPattern(); if (!s2.rotateToInterface(i1)) { return null; } int length = 2 * s1.period_length(); Siteswap mergedSiteswap = new Siteswap(new byte[length]); mergedSiteswap.setSynchronousStartPosition(s1.getSynchronousStartPosition()); mergedSiteswap.setNumberOfSynchronousHands(s1.getNumberOfSynchronousHands()); mergedSiteswap.setNumberOfJugglers(s1.getNumberOfJugglers()); for (int i = 0; i < s1.period_length(); ++i) { mergedSiteswap.set(2*i, s1.at(2*i)); mergedSiteswap.set(2*i+1, s2.at(2*i+1)); } if (!mergedSiteswap.isValid()) { return null; } return mergedSiteswap; } }
Siteswap implements Comparable<Siteswap>, Iterable<Byte>, Serializable { public static Siteswap mergeCompatible(Siteswap s1, Siteswap s2) { Siteswap i1 = s1.toInterface().toPattern(); Siteswap i2 = s2.toInterface().toPattern(); if (!s2.rotateToInterface(i1)) { return null; } int length = 2 * s1.period_length(); Siteswap mergedSiteswap = new Siteswap(new byte[length]); mergedSiteswap.setSynchronousStartPosition(s1.getSynchronousStartPosition()); mergedSiteswap.setNumberOfSynchronousHands(s1.getNumberOfSynchronousHands()); mergedSiteswap.setNumberOfJugglers(s1.getNumberOfJugglers()); for (int i = 0; i < s1.period_length(); ++i) { mergedSiteswap.set(2*i, s1.at(2*i)); mergedSiteswap.set(2*i+1, s2.at(2*i+1)); } if (!mergedSiteswap.isValid()) { return null; } return mergedSiteswap; } Siteswap();  Siteswap(Siteswap s);  Siteswap(byte[] data, int numberOfJugglers);  Siteswap(String siteswap, int numberOfJugglers, String name);  Siteswap(String siteswap, int numberOfJugglers);  Siteswap(String siteswap);  Siteswap(byte[] data); }
Siteswap implements Comparable<Siteswap>, Iterable<Byte>, Serializable { public static Siteswap mergeCompatible(Siteswap s1, Siteswap s2) { Siteswap i1 = s1.toInterface().toPattern(); Siteswap i2 = s2.toInterface().toPattern(); if (!s2.rotateToInterface(i1)) { return null; } int length = 2 * s1.period_length(); Siteswap mergedSiteswap = new Siteswap(new byte[length]); mergedSiteswap.setSynchronousStartPosition(s1.getSynchronousStartPosition()); mergedSiteswap.setNumberOfSynchronousHands(s1.getNumberOfSynchronousHands()); mergedSiteswap.setNumberOfJugglers(s1.getNumberOfJugglers()); for (int i = 0; i < s1.period_length(); ++i) { mergedSiteswap.set(2*i, s1.at(2*i)); mergedSiteswap.set(2*i+1, s2.at(2*i+1)); } if (!mergedSiteswap.isValid()) { return null; } return mergedSiteswap; } Siteswap();  Siteswap(Siteswap s);  Siteswap(byte[] data, int numberOfJugglers);  Siteswap(String siteswap, int numberOfJugglers, String name);  Siteswap(String siteswap, int numberOfJugglers);  Siteswap(String siteswap);  Siteswap(byte[] data); byte at(int index); byte atSyncCorrected(int index); void set(int index, int value); int period_length(); int local_period_length(); int global_period_length(); int getNonMirroredPeriod(); int getNumberOfHands(); void swap(int index); int getMaxThrow(); int getNumberOfObjects(); int getNumberOfJugglers(); boolean setNumberOfSynchronousHands(int numberOfSynchronousHands); int getNumberOfSynchronousHands(); void setSynchronousStartPosition(int synchronousStartPosition); int getSynchronousStartPosition(); String getSiteswapName(); void setSiteswapName(String name); int getPartialSum(int startIndex, int stopIndex); boolean is_in_range(byte min, byte max); boolean isSynchronous(); int getSynchronousPosition(int position); int countFilterValue(NumberFilter.FilterValue siteswapValue); int countFilterValuePartitially(NumberFilter.FilterValue siteswapValue, int index); void rotateRight(int positions); void rotateLeft(int positions); void make_unique_representation(); boolean rotateGetinFree(); Siteswap calculateGetin(); Siteswap calculateGetout(); boolean isGetinFree(); int calculateMandatoreyGetinLength(); Siteswap calculateMandatoryGetin(); Siteswap calculateNonMandatoryGetins(); Siteswap[] calculateLocalGetins(); Siteswap[] calculateLocalGetouts(); ClubDistribution[] calculateGroundStateClubDistribution(); ClubDistribution[] calculateInitialClubDistribution(); boolean isMandatoryGetin(); boolean isGroundStateClubDistribution(); int measureSuitabilityForStartingPosition(); void rotateToBestStartingPosition(); @Override Iterator<Byte> iterator(); @Override int compareTo(Siteswap o); byte[] toArray(); Vector<Siteswap> toLocal(); String toDividedString(); Vector<String> toLocalString(); @Override boolean equals(Object obj); @Override String toString(); String toGlobalString(); String toAsyncString(); String toSyncStringLocalVsLocal(); String toSyncStringGlobalRepresentation(); static String getCurrentStringVersion(); boolean fromParsableString(String str); boolean parseVersionedString(String version, String siteswapStr); String toParsableString(); Siteswap toPattern(); Siteswap toInterface(); Siteswap toInterface(byte defaultValue); Siteswap toInterface(byte defaultValue, int interfaceLength, int length); boolean isValid(); static Siteswap mergeCompatible(Siteswap s1, Siteswap s2); static boolean isValid(Siteswap siteswap); String stringAt(int index); static String intToString(int value); static int stringToInt(String value); static char intToChar(int value); static int charToInt(char value); boolean isPatternSingleValue(byte patternValue, byte siteswapValue); boolean isPattern(Siteswap pattern); boolean isPattern(Siteswap pattern, int patternStartPosition); boolean rotateToInterface(Siteswap siteswapInterface); boolean isParsingError(); String getInvalidCharactersFromParsing(); static boolean isPass(int value, int numberOfJugglers); static boolean isSelf(int value, int numberOfJugglers); }
Siteswap implements Comparable<Siteswap>, Iterable<Byte>, Serializable { public static Siteswap mergeCompatible(Siteswap s1, Siteswap s2) { Siteswap i1 = s1.toInterface().toPattern(); Siteswap i2 = s2.toInterface().toPattern(); if (!s2.rotateToInterface(i1)) { return null; } int length = 2 * s1.period_length(); Siteswap mergedSiteswap = new Siteswap(new byte[length]); mergedSiteswap.setSynchronousStartPosition(s1.getSynchronousStartPosition()); mergedSiteswap.setNumberOfSynchronousHands(s1.getNumberOfSynchronousHands()); mergedSiteswap.setNumberOfJugglers(s1.getNumberOfJugglers()); for (int i = 0; i < s1.period_length(); ++i) { mergedSiteswap.set(2*i, s1.at(2*i)); mergedSiteswap.set(2*i+1, s2.at(2*i+1)); } if (!mergedSiteswap.isValid()) { return null; } return mergedSiteswap; } Siteswap();  Siteswap(Siteswap s);  Siteswap(byte[] data, int numberOfJugglers);  Siteswap(String siteswap, int numberOfJugglers, String name);  Siteswap(String siteswap, int numberOfJugglers);  Siteswap(String siteswap);  Siteswap(byte[] data); byte at(int index); byte atSyncCorrected(int index); void set(int index, int value); int period_length(); int local_period_length(); int global_period_length(); int getNonMirroredPeriod(); int getNumberOfHands(); void swap(int index); int getMaxThrow(); int getNumberOfObjects(); int getNumberOfJugglers(); boolean setNumberOfSynchronousHands(int numberOfSynchronousHands); int getNumberOfSynchronousHands(); void setSynchronousStartPosition(int synchronousStartPosition); int getSynchronousStartPosition(); String getSiteswapName(); void setSiteswapName(String name); int getPartialSum(int startIndex, int stopIndex); boolean is_in_range(byte min, byte max); boolean isSynchronous(); int getSynchronousPosition(int position); int countFilterValue(NumberFilter.FilterValue siteswapValue); int countFilterValuePartitially(NumberFilter.FilterValue siteswapValue, int index); void rotateRight(int positions); void rotateLeft(int positions); void make_unique_representation(); boolean rotateGetinFree(); Siteswap calculateGetin(); Siteswap calculateGetout(); boolean isGetinFree(); int calculateMandatoreyGetinLength(); Siteswap calculateMandatoryGetin(); Siteswap calculateNonMandatoryGetins(); Siteswap[] calculateLocalGetins(); Siteswap[] calculateLocalGetouts(); ClubDistribution[] calculateGroundStateClubDistribution(); ClubDistribution[] calculateInitialClubDistribution(); boolean isMandatoryGetin(); boolean isGroundStateClubDistribution(); int measureSuitabilityForStartingPosition(); void rotateToBestStartingPosition(); @Override Iterator<Byte> iterator(); @Override int compareTo(Siteswap o); byte[] toArray(); Vector<Siteswap> toLocal(); String toDividedString(); Vector<String> toLocalString(); @Override boolean equals(Object obj); @Override String toString(); String toGlobalString(); String toAsyncString(); String toSyncStringLocalVsLocal(); String toSyncStringGlobalRepresentation(); static String getCurrentStringVersion(); boolean fromParsableString(String str); boolean parseVersionedString(String version, String siteswapStr); String toParsableString(); Siteswap toPattern(); Siteswap toInterface(); Siteswap toInterface(byte defaultValue); Siteswap toInterface(byte defaultValue, int interfaceLength, int length); boolean isValid(); static Siteswap mergeCompatible(Siteswap s1, Siteswap s2); static boolean isValid(Siteswap siteswap); String stringAt(int index); static String intToString(int value); static int stringToInt(String value); static char intToChar(int value); static int charToInt(char value); boolean isPatternSingleValue(byte patternValue, byte siteswapValue); boolean isPattern(Siteswap pattern); boolean isPattern(Siteswap pattern, int patternStartPosition); boolean rotateToInterface(Siteswap siteswapInterface); boolean isParsingError(); String getInvalidCharactersFromParsing(); static boolean isPass(int value, int numberOfJugglers); static boolean isSelf(int value, int numberOfJugglers); static final byte SELF; static final byte PASS; static final byte DONT_CARE; static final byte FREE; static final byte INVALID; }