001/**
002 * AbstractBooleanPrimitive.java
003 * 
004 * Copyright (c) 2004-2012, Nicole C. Tedesco. All rights reserved.
005 * 
006 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
007 * use this file except in compliance with the License. You may obtain a copy of
008 * the License at:
009 * 
010 * http://www.apache.org/licenses/LICENSE-2.0
011 * 
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
014 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
015 * License for the specific language governing permissions and limitations under
016 * the License.
017 */
018
019package net.sf.jaccumulator.booleans;
020
021import java.math.BigDecimal;
022import java.math.BigInteger;
023import java.util.NoSuchElementException;
024
025import net.sf.jaccumulator.Domain;
026import net.sf.jaccumulator.StructureStrategy;
027import net.sf.jaccumulator.lex.To;
028import net.sf.jaccumulator.primitives.AbstractNumericPrimitive;
029import net.sf.jaccumulator.primitives.Constant;
030import net.sf.jaccumulator.primitives.Primitive;
031import net.sf.jaccumulator.primitives.SealedPrimitive;
032import net.sf.jaccumulator.reals.Real;
033import net.sf.jaccumulator.reals.SealedReal;
034import net.sf.jaccumulator.scalars.NumericPrecision;
035import net.sf.jaccumulator.scalars.RoundingStrategy;
036import net.sf.jaccumulator.scalars.Scalar;
037import net.sf.jaccumulator.scalars.SealedScalar;
038
039/**
040 * Abstract {@code boolean} precision {@link Primitive primitive} implementation
041 * 
042 * @param <PRIMITIVE>
043 *        this primitive type (used to facilitate operation chaining on write
044 *        operations)
045 * @since JAccumulator 4.0
046 * @author Nicole Tedesco (<a
047 *         href="mailto:Nicole@NicoleTedesco.com">Nicole@NicoleTedesco.com</a>)
048 */
049public abstract class AbstractBooleanPrimitive<PRIMITIVE extends AbstractBooleanPrimitive<PRIMITIVE>>
050    extends
051        AbstractNumericPrimitive<PRIMITIVE>
052{
053    private static final long serialVersionUID = 6896837901268631666L;
054
055    public AbstractBooleanPrimitive()
056    {
057        super(Domain.MODULO, NumericPrecision.BIT);
058    }
059
060    @Override
061    @SuppressWarnings( "unchecked" )
062    public final PRIMITIVE absoluteValue()
063        throws UnsupportedOperationException,
064            ArithmeticException,
065            IllegalArgumentException
066    {
067        return (PRIMITIVE)this;
068    }
069
070    @Override
071    public final PRIMITIVE and( final byte aValue )
072        throws UnsupportedOperationException,
073            IllegalArgumentException,
074            ArithmeticException
075    {
076        return this.and(To.booleanValue(aValue));
077    }
078
079    @Override
080    public final PRIMITIVE and( final char aValue )
081        throws UnsupportedOperationException,
082            IllegalArgumentException,
083            ArithmeticException
084    {
085        return this.and(To.booleanValue(aValue));
086    }
087
088    @Override
089    public final PRIMITIVE and( final int aValue )
090        throws UnsupportedOperationException,
091            IllegalArgumentException,
092            ArithmeticException
093    {
094        return this.and(To.booleanValue(aValue));
095    }
096
097    @Override
098    public final PRIMITIVE and( final long aValue )
099        throws UnsupportedOperationException,
100            IllegalArgumentException,
101            ArithmeticException
102    {
103        return this.and(To.booleanValue(aValue));
104    }
105
106    @Override
107    public final PRIMITIVE and( final short aValue )
108        throws UnsupportedOperationException,
109            IllegalArgumentException,
110            ArithmeticException
111    {
112        return this.and(To.booleanValue(aValue));
113    }
114
115    @Override
116    public final boolean booleanPostDecrement()
117        throws UnsupportedOperationException,
118            ArithmeticException,
119            IllegalArgumentException
120    {
121        final boolean myValue = this.booleanValue();
122        this.decrement();
123        return myValue;
124    }
125
126    @Override
127    public final boolean booleanPostIncrement()
128        throws UnsupportedOperationException,
129            ArithmeticException,
130            IllegalArgumentException
131    {
132        final boolean myValue = this.booleanValue();
133        this.increment();
134        return myValue;
135    }
136
137    @Override
138    public final byte bytePostDecrement()
139        throws UnsupportedOperationException,
140            ArithmeticException,
141            IllegalArgumentException
142    {
143        return To.byteValue(this.booleanPostDecrement());
144    }
145
146    @Override
147    public final byte bytePostIncrement()
148        throws UnsupportedOperationException,
149            ArithmeticException,
150            IllegalArgumentException
151    {
152        return To.byteValue(this.booleanPostIncrement());
153    }
154
155    @Override
156    public final byte byteValue()
157    {
158        return To.byteValue(this.booleanValue());
159    }
160
161    @Override
162    public final char charPostDecrement()
163        throws UnsupportedOperationException,
164            ArithmeticException,
165            IllegalArgumentException
166    {
167        return To.charValue(this.booleanPostDecrement());
168    }
169
170    @Override
171    public final char charPostIncrement()
172        throws UnsupportedOperationException,
173            ArithmeticException,
174            IllegalArgumentException
175    {
176        return To.charValue(this.booleanPostIncrement());
177    }
178
179    @Override
180    public final char charValue()
181    {
182        return To.charValue(this.booleanValue());
183    }
184
185    @Override
186    public PRIMITIVE copyUsing( final BigDecimal aValue )
187    {
188        return this.copyUsing(To.booleanValue(aValue));
189    }
190
191    @Override
192    public PRIMITIVE copyUsing( final BigInteger aValue )
193    {
194        return this.copyUsing(To.booleanValue(aValue));
195    }
196
197    @Override
198    public PRIMITIVE copyUsing( final byte aValue )
199    {
200        return this.copyUsing(To.booleanValue(aValue));
201    }
202
203    @Override
204    public PRIMITIVE copyUsing( final char aValue )
205    {
206        return this.copyUsing(To.booleanValue(aValue));
207    }
208
209    @Override
210    public PRIMITIVE copyUsing( final double aValue )
211    {
212        return this.copyUsing(To.booleanValue(aValue));
213    }
214
215    @Override
216    public PRIMITIVE copyUsing( final float aValue )
217    {
218        return this.copyUsing(To.booleanValue(aValue));
219    }
220
221    @Override
222    public PRIMITIVE copyUsing( final int aValue )
223    {
224        return this.copyUsing(To.booleanValue(aValue));
225    }
226
227    @Override
228    public PRIMITIVE copyUsing( final long aValue )
229    {
230        return this.copyUsing(To.booleanValue(aValue));
231    }
232
233    @Override
234    public PRIMITIVE copyUsing( final short aValue )
235    {
236        return this.copyUsing(To.booleanValue(aValue));
237    }
238
239    @Override
240    public PRIMITIVE copyUsingPrimitive( final SealedPrimitive<?> aValue )
241    {
242        return this.copyUsing(aValue.booleanValue());
243    }
244
245    @Override
246    public PRIMITIVE copyUsingReal( final SealedReal<?> aValue )
247    {
248        return this.copyUsing(aValue.booleanValue());
249    }
250
251    @Override
252    public PRIMITIVE copyUsingScalar( final SealedScalar<?> aValue )
253    {
254        return this.copyUsing(aValue.booleanValue());
255    }
256
257    @Override
258    @SuppressWarnings( "unchecked" )
259    public final PRIMITIVE cube()
260        throws UnsupportedOperationException,
261            IllegalArgumentException,
262            ArithmeticException
263    {
264        return (PRIMITIVE)this;
265    }
266
267    @Override
268    public final PRIMITIVE decrement()
269        throws UnsupportedOperationException,
270            IllegalArgumentException,
271            ArithmeticException
272    {
273        return this.not();
274    }
275
276    @Override
277    public final PRIMITIVE difference( final BigDecimal aValue )
278        throws UnsupportedOperationException,
279            IllegalArgumentException,
280            ArithmeticException
281    {
282        if (this.booleanValue())
283            return this.setReal(aValue.subtract(BigDecimal.ONE));
284        return this.setReal(aValue);
285    }
286
287    @Override
288    public final PRIMITIVE difference( final BigInteger aValue )
289        throws UnsupportedOperationException,
290            IllegalArgumentException,
291            ArithmeticException
292    {
293        if (this.booleanValue())
294            return this.setReal(aValue.subtract(BigInteger.ONE));
295        return this.setReal(aValue);
296    }
297
298    @Override
299    public final PRIMITIVE difference( final boolean aValue )
300        throws UnsupportedOperationException,
301            IllegalArgumentException,
302            ArithmeticException
303    {
304        return this.xor(aValue);
305    }
306
307    @Override
308    public final PRIMITIVE difference( final byte aValue )
309        throws UnsupportedOperationException,
310            IllegalArgumentException,
311            ArithmeticException
312    {
313        if (this.booleanValue()) return this.setScalar(aValue - (byte)1);
314        return this.setScalar(aValue);
315    }
316
317    @Override
318    public final PRIMITIVE difference( final char aValue )
319        throws UnsupportedOperationException,
320            IllegalArgumentException,
321            ArithmeticException
322    {
323        if (this.booleanValue()) return this.setScalar(aValue - (char)1);
324        return this.setScalar(aValue);
325    }
326
327    @Override
328    public final PRIMITIVE difference( final double aValue )
329        throws UnsupportedOperationException,
330            IllegalArgumentException,
331            ArithmeticException
332    {
333        if (this.booleanValue()) return this.setScalar(aValue - 1);
334        return this.setScalar(aValue);
335    }
336
337    @Override
338    public final PRIMITIVE difference( final float aValue )
339        throws UnsupportedOperationException,
340            IllegalArgumentException,
341            ArithmeticException
342    {
343        if (this.booleanValue()) return this.setScalar(aValue - 1);
344        return this.setScalar(aValue);
345    }
346
347    @Override
348    public final PRIMITIVE difference( final int aValue )
349        throws UnsupportedOperationException,
350            IllegalArgumentException,
351            ArithmeticException
352    {
353        if (this.booleanValue()) return this.setScalar(aValue - 1);
354        return this.setScalar(aValue);
355    }
356
357    @Override
358    public final PRIMITIVE difference( final long aValue )
359        throws UnsupportedOperationException,
360            IllegalArgumentException,
361            ArithmeticException
362    {
363        if (this.booleanValue()) return this.setScalar(aValue - 1);
364        return this.setScalar(aValue);
365    }
366
367    @Override
368    public final PRIMITIVE difference( final short aValue )
369        throws UnsupportedOperationException,
370            IllegalArgumentException,
371            ArithmeticException
372    {
373        if (this.booleanValue()) return this.setScalar(aValue - (short)1);
374        return this.setScalar(aValue);
375    }
376
377    @Override
378    public final double doublePostDecrement()
379        throws UnsupportedOperationException,
380            ArithmeticException,
381            IllegalArgumentException
382    {
383        return To.doubleValue(this.booleanPostDecrement());
384    }
385
386    @Override
387    public final double doublePostIncrement()
388        throws UnsupportedOperationException,
389            ArithmeticException,
390            IllegalArgumentException
391    {
392        return To.doubleValue(this.booleanPostIncrement());
393    }
394
395    @Override
396    public final double doubleValue()
397    {
398        return To.doubleValue(this.booleanValue());
399    }
400
401    @Override
402    public final float floatPostDecrement()
403        throws UnsupportedOperationException,
404            ArithmeticException,
405            IllegalArgumentException
406    {
407        return To.floatValue(this.booleanPostDecrement());
408    }
409
410    @Override
411    public final float floatPostIncrement()
412        throws UnsupportedOperationException,
413            ArithmeticException,
414            IllegalArgumentException
415    {
416        return To.floatValue(this.booleanPostIncrement());
417    }
418
419    @Override
420    public final float floatValue()
421    {
422        return To.floatValue(this.booleanValue());
423    }
424
425    @Override
426    public final StructureStrategy getStructureStrategy()
427    {
428        return StructureStrategy.SINGLETON;
429    }
430
431    @Override
432    public final int hashCode()
433    {
434        return hashCode(this.booleanValue());
435    }
436
437    @Override
438    public final PRIMITIVE increment()
439        throws UnsupportedOperationException,
440            ArithmeticException,
441            IllegalArgumentException
442    {
443        return this.not();
444    }
445
446    @Override
447    @SuppressWarnings( "unchecked" )
448    public final <S extends Scalar<?>> S inducePostDecrement( final S aTarget )
449        throws NullPointerException,
450            NoSuchElementException,
451            UnsupportedOperationException,
452            IllegalStateException
453    {
454        return (S)aTarget.setScalar(this.booleanPostDecrement());
455    }
456
457    @Override
458    @SuppressWarnings( "unchecked" )
459    public final <S extends Scalar<?>> S inducePostIncrement( final S aTarget )
460        throws NullPointerException,
461            NoSuchElementException,
462            UnsupportedOperationException,
463            IllegalStateException
464    {
465        return (S)aTarget.setScalar(this.booleanPostIncrement());
466    }
467
468    @Override
469    public final <REAL extends Real<?>> REAL induceRealMaximum(
470        final REAL aTarget )
471        throws NullPointerException,
472            NoSuchElementException,
473            UnsupportedOperationException,
474            IllegalStateException
475    {
476        return this.induceScalarMaximum(aTarget);
477    }
478
479    @Override
480    public final <REAL extends Real<?>> REAL induceRealMinimum(
481        final REAL aTarget )
482        throws NullPointerException,
483            NoSuchElementException,
484            UnsupportedOperationException,
485            IllegalStateException
486    {
487        return this.induceScalarMinimum(aTarget);
488    }
489
490    @Override
491    public final <REAL extends Real<?>> REAL induceRealValue( final REAL aTarget )
492        throws NullPointerException,
493            NoSuchElementException,
494            UnsupportedOperationException,
495            IllegalStateException
496    {
497        return this.induceScalarValue(aTarget);
498    }
499
500    @Override
501    @SuppressWarnings( "unchecked" )
502    public final <S extends Scalar<?>> S induceScalarMaximum( final S aTarget )
503    {
504        return (S)aTarget.setTrue();
505    }
506
507    @Override
508    @SuppressWarnings( "unchecked" )
509    public final <S extends Scalar<?>> S induceScalarMinimum( final S aTarget )
510    {
511        return (S)aTarget.setFalse();
512    }
513
514    @Override
515    @SuppressWarnings( "unchecked" )
516    public final <S extends Scalar<?>> S induceScalarValue( final S aTarget )
517    {
518        return (S)aTarget.setScalar(this.booleanValue());
519    }
520
521    @Override
522    public final int intPostDecrement()
523        throws UnsupportedOperationException,
524            ArithmeticException,
525            IllegalArgumentException
526    {
527        return To.intValue(this.booleanPostDecrement());
528    }
529
530    @Override
531    public final int intPostIncrement()
532        throws UnsupportedOperationException,
533            ArithmeticException,
534            IllegalArgumentException
535    {
536        return To.intValue(this.booleanPostIncrement());
537    }
538
539    @Override
540    public final int intValue()
541    {
542        return To.intValue(this.booleanValue());
543    }
544
545    @Override
546    public final PRIMITIVE invalidate()
547        throws UnsupportedOperationException,
548            ArithmeticException,
549            IllegalArgumentException
550    {
551        return this.setScalar(false);
552    }
553
554    @Override
555    @SuppressWarnings( "unchecked" )
556    public final PRIMITIVE inverse()
557        throws UnsupportedOperationException,
558            ArithmeticException,
559            IllegalArgumentException
560    {
561        if (this.booleanValue()) return (PRIMITIVE)this;
562        return this.quotient(0);
563    }
564
565    @Override
566    public final boolean isDigit()
567    {
568        return Character.isDigit(this.charValue());
569    }
570
571    @Override
572    public final boolean isFinite()
573    {
574        return true;
575    }
576
577    @Override
578    public final boolean isIdentifierIgnorable()
579    {
580        return Character.isIdentifierIgnorable(this.charValue());
581    }
582
583    @Override
584    public final boolean isInfinity()
585    {
586        return false;
587    }
588
589    @Override
590    public final boolean isInvalid()
591    {
592        return false;
593    }
594
595    @Override
596    public final boolean isISOControl()
597    {
598        return Character.isISOControl(this.charValue());
599    }
600
601    @Override
602    public final boolean isJavaIdentifierPart()
603    {
604        return Character.isJavaIdentifierPart(this.charValue());
605    }
606
607    @Override
608    public final boolean isJavaIdentifierStart()
609    {
610        return Character.isJavaIdentifierStart(this.charValue());
611    }
612
613    @Override
614    public final boolean isLetter()
615    {
616        return Character.isLetter(this.charValue());
617    }
618
619    @Override
620    public final boolean isLetterOrDigit()
621    {
622        return Character.isLetterOrDigit(this.charValue());
623    }
624
625    @Override
626    public final boolean isLowerCase()
627    {
628        return Character.isLowerCase(this.charValue());
629    }
630
631    @Override
632    public final boolean isMaximum()
633    {
634        return this.booleanValue();
635    }
636
637    @Override
638    public final boolean isMinimum()
639    {
640        return !this.booleanValue();
641    }
642
643    @Override
644    public final boolean isMirrored()
645    {
646        return Character.isMirrored(this.charValue());
647    }
648
649    @Override
650    public final boolean isModulo()
651    {
652        return true;
653    }
654
655    @Override
656    public final boolean isNegative()
657    {
658        return false;
659    }
660
661    @Override
662    public final boolean isNegativeFinite()
663    {
664        return false;
665    }
666
667    @Override
668    public final boolean isNegativeInfinity()
669    {
670        return false;
671    }
672
673    @Override
674    public final boolean isOrdered()
675    {
676        return true;
677    }
678
679    @Override
680    public final boolean isPositive()
681    {
682        return this.booleanValue();
683    }
684
685    @Override
686    public final boolean isPositiveFinite()
687    {
688        return this.booleanValue();
689    }
690
691    @Override
692    public final boolean isPositiveInfinity()
693    {
694        return false;
695    }
696
697    @Override
698    public final boolean isReal()
699    {
700        return true;
701    }
702
703    @Override
704    public final boolean isTitleCase()
705    {
706        return Character.isTitleCase(this.charValue());
707    }
708
709    @Override
710    public final boolean isUnicode()
711    {
712        return Character.isDefined(this.charValue());
713    }
714
715    @Override
716    public final boolean isUnicodeIdentifierPart()
717    {
718        return Character.isUnicodeIdentifierPart(this.charValue());
719    }
720
721    @Override
722    public final boolean isUnicodeIdentifierStart()
723    {
724        return Character.isUnicodeIdentifierStart(this.charValue());
725    }
726
727    @Override
728    public final boolean isUnique()
729    {
730        return true;
731    }
732
733    @Override
734    public final boolean isUnity()
735    {
736        return this.booleanValue();
737    }
738
739    @Override
740    public final boolean isUpperCase()
741    {
742        return Character.isUpperCase(this.charValue());
743    }
744
745    @Override
746    public final boolean isWhitespace()
747    {
748        return Character.isWhitespace(this.charValue());
749    }
750
751    @Override
752    public final boolean isZero()
753    {
754        return !this.booleanValue();
755    }
756
757    @Override
758    public final long longPostDecrement()
759        throws UnsupportedOperationException,
760            ArithmeticException,
761            IllegalArgumentException
762    {
763        return To.longValue(this.booleanPostDecrement());
764    }
765
766    @Override
767    public final long longPostIncrement()
768        throws UnsupportedOperationException,
769            ArithmeticException,
770            IllegalArgumentException
771    {
772        return To.longValue(this.booleanPostIncrement());
773    }
774
775    @Override
776    public final long longValue()
777    {
778        return To.longValue(this.booleanValue());
779    }
780
781    @Override
782    public final PRIMITIVE lowerCase()
783    {
784        return this.setScalar(Character.toLowerCase(this.charValue()));
785    }
786
787    @Override
788    public final PRIMITIVE mod( final boolean aValue )
789        throws UnsupportedOperationException,
790            IllegalArgumentException,
791            ArithmeticException
792    {
793        return this.quotient(aValue);
794    }
795
796    @Override
797    @SuppressWarnings( "unchecked" )
798    public final PRIMITIVE negate()
799        throws UnsupportedOperationException,
800            ArithmeticException,
801            IllegalArgumentException
802    {
803        return (PRIMITIVE)this;
804    }
805
806    @Override
807    public final PRIMITIVE or( final byte aValue )
808        throws UnsupportedOperationException,
809            IllegalArgumentException,
810            ArithmeticException
811    {
812        return this.or(To.booleanValue(aValue));
813    }
814
815    @Override
816    public final PRIMITIVE or( final char aValue )
817        throws UnsupportedOperationException,
818            IllegalArgumentException,
819            ArithmeticException
820    {
821        return this.or(To.booleanValue(aValue));
822    }
823
824    @Override
825    public final PRIMITIVE or( final int aValue )
826        throws UnsupportedOperationException,
827            IllegalArgumentException,
828            ArithmeticException
829    {
830        return this.or(To.booleanValue(aValue));
831    }
832
833    @Override
834    public final PRIMITIVE or( final long aValue )
835        throws UnsupportedOperationException,
836            IllegalArgumentException,
837            ArithmeticException
838    {
839        return this.or(To.booleanValue(aValue));
840    }
841
842    @Override
843    public final PRIMITIVE or( final short aValue )
844        throws UnsupportedOperationException,
845            IllegalArgumentException,
846            ArithmeticException
847    {
848        return this.or(To.booleanValue(aValue));
849    }
850
851    @Override
852    public final PRIMITIVE product( final BigDecimal aValue )
853        throws UnsupportedOperationException,
854            IllegalArgumentException,
855            ArithmeticException
856    {
857        if (this.booleanValue()) return this.setReal(aValue);
858        return this.setScalar(false);
859    }
860
861    @Override
862    public final PRIMITIVE product( final BigInteger aValue )
863        throws UnsupportedOperationException,
864            IllegalArgumentException,
865            ArithmeticException
866    {
867        if (this.booleanValue()) return this.setReal(aValue);
868        return this.setScalar(false);
869    }
870
871    @Override
872    public final PRIMITIVE product( final boolean aValue )
873        throws UnsupportedOperationException,
874            IllegalArgumentException,
875            ArithmeticException
876    {
877        return this.and(aValue);
878    }
879
880    @Override
881    public final PRIMITIVE product( final byte aValue )
882        throws UnsupportedOperationException,
883            IllegalArgumentException,
884            ArithmeticException
885    {
886        if (this.booleanValue()) return this.setScalar(aValue);
887        return this.setScalar(false);
888    }
889
890    @Override
891    public final PRIMITIVE product( final char aValue )
892        throws UnsupportedOperationException,
893            IllegalArgumentException,
894            ArithmeticException
895    {
896        if (this.booleanValue()) return this.setScalar(aValue);
897        return this.setScalar(false);
898    }
899
900    @Override
901    public final PRIMITIVE product( final double aValue )
902        throws UnsupportedOperationException,
903            IllegalArgumentException,
904            ArithmeticException
905    {
906        if (this.booleanValue()) return this.setScalar(aValue);
907        return this.setScalar(false);
908    }
909
910    @Override
911    public final PRIMITIVE product( final float aValue )
912        throws UnsupportedOperationException,
913            IllegalArgumentException,
914            ArithmeticException
915    {
916        if (this.booleanValue()) return this.setScalar(aValue);
917        return this.setScalar(false);
918    }
919
920    @Override
921    public final PRIMITIVE product( final int aValue )
922        throws UnsupportedOperationException,
923            IllegalArgumentException,
924            ArithmeticException
925    {
926        if (this.booleanValue()) return this.setScalar(aValue);
927        return this.setScalar(false);
928    }
929
930    @Override
931    public final PRIMITIVE product( final long aValue )
932        throws UnsupportedOperationException,
933            IllegalArgumentException,
934            ArithmeticException
935    {
936        if (this.booleanValue()) return this.setScalar(aValue);
937        return this.setScalar(false);
938    }
939
940    @Override
941    public final PRIMITIVE product( final short aValue )
942        throws UnsupportedOperationException,
943            IllegalArgumentException,
944            ArithmeticException
945    {
946        if (this.booleanValue()) return this.setScalar(aValue);
947        return this.setScalar(false);
948    }
949
950    @Override
951    @SuppressWarnings( "unchecked" )
952    public final PRIMITIVE quotient( final boolean aValue )
953        throws UnsupportedOperationException,
954            IllegalArgumentException,
955            ArithmeticException
956    {
957        if (!aValue) {
958            @SuppressWarnings( "unused" )
959            final int i = 1 / 0;
960        }
961        return (PRIMITIVE)this;
962    }
963
964    @Override
965    @SuppressWarnings( "unchecked" )
966    public final PRIMITIVE round( final RoundingStrategy aRoundingStrategy )
967        throws UnsupportedOperationException,
968            IllegalArgumentException,
969            ArithmeticException,
970            NullPointerException
971    {
972        return (PRIMITIVE)this;
973    }
974
975    @Override
976    public final PRIMITIVE setMaximum()
977        throws UnsupportedOperationException,
978            ArithmeticException,
979            IllegalArgumentException
980    {
981        return this.setScalar(true);
982    }
983
984    @Override
985    public final PRIMITIVE setMinimum()
986        throws UnsupportedOperationException,
987            ArithmeticException,
988            IllegalArgumentException
989    {
990        return this.setScalar(false);
991    }
992
993    @Override
994    public final PRIMITIVE setPrimitive( final SealedPrimitive<?> aValue )
995        throws UnsupportedOperationException,
996            IllegalArgumentException,
997            ArithmeticException,
998            NullPointerException
999    {
1000        return this.setScalar(aValue.booleanValue());
1001    }
1002
1003    @Override
1004    public final PRIMITIVE setReal( final BigDecimal aValue )
1005        throws UnsupportedOperationException,
1006            IllegalArgumentException,
1007            ArithmeticException,
1008            NullPointerException
1009    {
1010        return this.setScalar(To.booleanValue(aValue));
1011    }
1012
1013    @Override
1014    public final PRIMITIVE setReal( final BigInteger aValue )
1015        throws UnsupportedOperationException,
1016            IllegalArgumentException,
1017            ArithmeticException,
1018            NullPointerException
1019    {
1020        return this.setScalar(To.booleanValue(aValue));
1021    }
1022
1023    @Override
1024    public final PRIMITIVE setReal( final SealedReal<?> aValue )
1025        throws UnsupportedOperationException,
1026            IllegalArgumentException,
1027            ArithmeticException,
1028            NullPointerException
1029    {
1030        return this.setScalar(aValue.booleanValue());
1031    }
1032
1033    @Override
1034    public final PRIMITIVE setScalar( final byte aValue )
1035        throws UnsupportedOperationException,
1036            IllegalArgumentException,
1037            ArithmeticException
1038    {
1039        return this.setScalar(To.booleanValue(aValue));
1040    }
1041
1042    @Override
1043    public final PRIMITIVE setScalar( final char aValue )
1044        throws UnsupportedOperationException,
1045            IllegalArgumentException,
1046            ArithmeticException
1047    {
1048        return this.setScalar(To.booleanValue(aValue));
1049    }
1050
1051    @Override
1052    public final PRIMITIVE setScalar( final double aValue )
1053        throws UnsupportedOperationException,
1054            IllegalArgumentException,
1055            ArithmeticException
1056    {
1057        return this.setScalar(To.booleanValue(aValue));
1058    }
1059
1060    @Override
1061    public final PRIMITIVE setScalar( final float aValue )
1062        throws UnsupportedOperationException,
1063            IllegalArgumentException,
1064            ArithmeticException
1065    {
1066        return this.setScalar(To.booleanValue(aValue));
1067    }
1068
1069    @Override
1070    public final PRIMITIVE setScalar( final int aValue )
1071        throws UnsupportedOperationException,
1072            IllegalArgumentException,
1073            ArithmeticException
1074    {
1075        return this.setScalar(To.booleanValue(aValue));
1076    }
1077
1078    @Override
1079    public final PRIMITIVE setScalar( final long aValue )
1080        throws UnsupportedOperationException,
1081            IllegalArgumentException,
1082            ArithmeticException
1083    {
1084        return this.setScalar(To.booleanValue(aValue));
1085    }
1086
1087    @Override
1088    public final PRIMITIVE setScalar( final SealedScalar<?> aValue )
1089        throws UnsupportedOperationException,
1090            IllegalArgumentException,
1091            ArithmeticException,
1092            NullPointerException
1093    {
1094        return this.setScalar(aValue.booleanValue());
1095    }
1096
1097    @Override
1098    public final PRIMITIVE setScalar( final short aValue )
1099        throws UnsupportedOperationException,
1100            IllegalArgumentException,
1101            ArithmeticException
1102    {
1103        return this.setScalar(To.booleanValue(aValue));
1104    }
1105
1106    @Override
1107    public final PRIMITIVE setUnity()
1108        throws UnsupportedOperationException,
1109            IllegalArgumentException,
1110            ArithmeticException
1111    {
1112        return this.setScalar(true);
1113    }
1114
1115    @Override
1116    public final PRIMITIVE setZero()
1117        throws UnsupportedOperationException,
1118            IllegalArgumentException,
1119            ArithmeticException
1120    {
1121        return this.setScalar(false);
1122    }
1123
1124    @Override
1125    @SuppressWarnings( "unchecked" )
1126    public final PRIMITIVE shiftLeft( final int count )
1127        throws UnsupportedOperationException,
1128            IllegalArgumentException,
1129            ArithmeticException
1130    {
1131        return count == 0 ? (PRIMITIVE)this : this.setScalar(false);
1132    }
1133
1134    @Override
1135    @SuppressWarnings( "unchecked" )
1136    public final PRIMITIVE shiftRight( final int count )
1137        throws UnsupportedOperationException,
1138            IllegalArgumentException,
1139            ArithmeticException
1140    {
1141        return count == 0 ? (PRIMITIVE)this : this.setScalar(false);
1142    }
1143
1144    @Override
1145    public final short shortPostDecrement()
1146        throws UnsupportedOperationException,
1147            ArithmeticException,
1148            IllegalArgumentException
1149    {
1150        return To.shortValue(this.booleanPostDecrement());
1151    }
1152
1153    @Override
1154    public final short shortPostIncrement()
1155        throws UnsupportedOperationException,
1156            ArithmeticException,
1157            IllegalArgumentException
1158    {
1159        return To.shortValue(this.booleanPostIncrement());
1160    }
1161
1162    @Override
1163    public final short shortValue()
1164    {
1165        return To.shortValue(this.booleanValue());
1166    }
1167
1168    @Override
1169    public final int signum()
1170    {
1171        return To.intValue(this.booleanValue());
1172    }
1173
1174    @Override
1175    @SuppressWarnings( "unchecked" )
1176    public final PRIMITIVE square()
1177        throws UnsupportedOperationException,
1178            IllegalArgumentException,
1179            ArithmeticException
1180    {
1181        return (PRIMITIVE)this;
1182    }
1183
1184    @Override
1185    public final PRIMITIVE sum( final BigDecimal aValue )
1186        throws UnsupportedOperationException,
1187            IllegalArgumentException,
1188            ArithmeticException
1189    {
1190        if (this.booleanValue())
1191            return this.setReal(aValue.add(BigDecimal.ONE));
1192        return this.setReal(aValue);
1193    }
1194
1195    @Override
1196    public final PRIMITIVE sum( final BigInteger aValue )
1197        throws UnsupportedOperationException,
1198            IllegalArgumentException,
1199            ArithmeticException
1200    {
1201        if (this.booleanValue())
1202            return this.setReal(aValue.add(BigInteger.ONE));
1203        return this.setReal(aValue);
1204    }
1205
1206    @Override
1207    public final PRIMITIVE sum( final boolean aValue )
1208        throws UnsupportedOperationException,
1209            IllegalArgumentException,
1210            ArithmeticException
1211    {
1212        return this.xor(aValue);
1213    }
1214
1215    @Override
1216    public final PRIMITIVE sum( final byte aValue )
1217        throws UnsupportedOperationException,
1218            IllegalArgumentException,
1219            ArithmeticException
1220    {
1221        if (this.booleanValue()) return this.setScalar(aValue + (byte)1);
1222        return this.setScalar(aValue);
1223    }
1224
1225    @Override
1226    public final PRIMITIVE sum( final char aValue )
1227        throws UnsupportedOperationException,
1228            IllegalArgumentException,
1229            ArithmeticException
1230    {
1231        if (this.booleanValue()) return this.setScalar(aValue + (char)1);
1232        return this.setScalar(aValue);
1233    }
1234
1235    @Override
1236    public final PRIMITIVE sum( final double aValue )
1237        throws UnsupportedOperationException,
1238            IllegalArgumentException,
1239            ArithmeticException
1240    {
1241        if (this.booleanValue()) return this.setScalar(aValue + 1);
1242        return this.setScalar(aValue);
1243    }
1244
1245    @Override
1246    public final PRIMITIVE sum( final float aValue )
1247        throws UnsupportedOperationException,
1248            IllegalArgumentException,
1249            ArithmeticException
1250    {
1251        if (this.booleanValue()) return this.setScalar(aValue + 1);
1252        return this.setScalar(aValue);
1253    }
1254
1255    @Override
1256    public final PRIMITIVE sum( final int aValue )
1257        throws UnsupportedOperationException,
1258            IllegalArgumentException,
1259            ArithmeticException
1260    {
1261        if (this.booleanValue()) return this.setScalar(aValue + 1);
1262        return this.setScalar(aValue);
1263    }
1264
1265    @Override
1266    public final PRIMITIVE sum( final long aValue )
1267        throws UnsupportedOperationException,
1268            IllegalArgumentException,
1269            ArithmeticException
1270    {
1271        if (this.booleanValue()) return this.setScalar(aValue + 1);
1272        return this.setScalar(aValue);
1273    }
1274
1275    @Override
1276    public final PRIMITIVE sum( final short aValue )
1277        throws UnsupportedOperationException,
1278            IllegalArgumentException,
1279            ArithmeticException
1280    {
1281        if (this.booleanValue()) return this.setScalar(aValue + (short)1);
1282        return this.setScalar(aValue);
1283    }
1284
1285    @Override
1286    public final PRIMITIVE swapPrimitives( final Primitive<?> aPrimitive )
1287    {
1288        final boolean myValue = this.booleanValue();
1289        final boolean aValue = aPrimitive.booleanValue();
1290        aPrimitive.setScalar(myValue);
1291        return this.setScalar(aValue);
1292    }
1293
1294    @Override
1295    public final PRIMITIVE titleCase()
1296    {
1297        return this.setScalar(Character.toTitleCase(this.charValue()));
1298    }
1299
1300    @Override
1301    public final Number toNumber()
1302    {
1303        return this.booleanValue() ? ONEI : ZEROI;
1304    }
1305
1306    @Override
1307    public final String toString()
1308    {
1309        return String.valueOf(this.booleanValue());
1310    }
1311
1312    @Override
1313    public final BigDecimal toUnlimitedDecimal()
1314    {
1315        return Constant.toUnlimitedDecimal(this.longValue());
1316    }
1317
1318    @Override
1319    public final BigInteger toUnlimitedInteger()
1320    {
1321        return Constant.toUnlimitedInteger(this.longValue());
1322    }
1323
1324    @Override
1325    public final BigDecimal unlimitedDecimalPostDecrement()
1326        throws UnsupportedOperationException,
1327            ArithmeticException,
1328            IllegalArgumentException
1329    {
1330        return Constant.toUnlimitedDecimal(this.booleanPostDecrement());
1331    }
1332
1333    @Override
1334    public final BigDecimal unlimitedDecimalPostIncrement()
1335        throws UnsupportedOperationException,
1336            ArithmeticException,
1337            IllegalArgumentException
1338    {
1339        return Constant.toUnlimitedDecimal(this.booleanPostIncrement());
1340    }
1341
1342    @Override
1343    public final BigInteger unlimitedIntegerPostDecrement()
1344        throws UnsupportedOperationException,
1345            ArithmeticException,
1346            IllegalArgumentException
1347    {
1348        return Constant.toUnlimitedInteger(this.booleanPostDecrement());
1349    }
1350
1351    @Override
1352    public final BigInteger unlimitedIntegerPostIncrement()
1353        throws UnsupportedOperationException,
1354            ArithmeticException,
1355            IllegalArgumentException
1356    {
1357        return Constant.toUnlimitedInteger(this.booleanPostIncrement());
1358    }
1359
1360    @Override
1361    public final PRIMITIVE upperCase()
1362    {
1363        return this.setScalar(Character.toUpperCase(this.charValue()));
1364    }
1365
1366    @Override
1367    public final PRIMITIVE xor( final byte aValue )
1368        throws UnsupportedOperationException,
1369            IllegalArgumentException,
1370            ArithmeticException
1371    {
1372        return this.xor(To.booleanValue(aValue));
1373    }
1374
1375    @Override
1376    public final PRIMITIVE xor( final char aValue )
1377        throws UnsupportedOperationException,
1378            IllegalArgumentException,
1379            ArithmeticException
1380    {
1381        return this.xor(To.booleanValue(aValue));
1382    }
1383
1384    @Override
1385    public final PRIMITIVE xor( final int aValue )
1386        throws UnsupportedOperationException,
1387            IllegalArgumentException,
1388            ArithmeticException
1389    {
1390        return this.xor(To.booleanValue(aValue));
1391    }
1392
1393    @Override
1394    public final PRIMITIVE xor( final long aValue )
1395        throws UnsupportedOperationException,
1396            IllegalArgumentException,
1397            ArithmeticException
1398    {
1399        return this.xor(To.booleanValue(aValue));
1400    }
1401
1402    @Override
1403    public final PRIMITIVE xor( final short aValue )
1404        throws UnsupportedOperationException,
1405            IllegalArgumentException,
1406            ArithmeticException
1407    {
1408        return this.xor(To.booleanValue(aValue));
1409    }
1410}