001/** 002 * StructureProperties.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; 020 021import java.util.Set; 022import java.util.SortedSet; 023 024import net.sf.jaccumulator.primitives.Variant; 025import net.sf.jaccumulator.scalars.MutableScalarDomain; 026import net.sf.jaccumulator.scalars.NumericPrecision; 027 028/** 029 * Prepositions for querying general properties of algebraic 030 * {@link AlgebraicStructure structures} 031 * 032 * @since JAccumulator 4.0 033 * @author Nicole Tedesco (<a 034 * href="mailto:Nicole@NicoleTedesco.com">Nicole@NicoleTedesco.com</a>) 035 */ 036public interface StructureProperties 037{ 038 /** 039 * Answer {@code true} if the implementation of this object can be changed.<br/> 040 * <br/> 041 * A configurable object has a structure that can be {@link #isExpandable() 042 * expanded}, or {@link #isReducible() reduced}, or has replaceable 043 * components. Configurable structures are necessarily 044 * {@link Mutable#isMutable() mutable}; in fact, "configurability" can be 045 * used as a strict definition of mutability. This predicate however 046 * overrides {@link #isMutable} in the respect that, for some types of 047 * objects such as {@link Variant Variants}, mutability can be changed by 048 * switching from a non-mutable implementation to a mutable one (e.g., via 049 * {@link MutableScalarDomain#assertPrecision(NumericPrecision) 050 * assertPrecision}). 051 * 052 * @return {@code true} if the implementation of this object can be changed 053 */ 054 public boolean isConfigurable(); 055 056 /** 057 * Answer {@code true} if this structure contains a countable number of 058 * elements. A countable set is a set with the same cardinality as some 059 * subset of the set of natural numbers. A set that is not countable 060 * contains an infinite number of elements. 061 * 062 * @return {@code true} if this structure contains a <i>countable</i> number 063 * of elements, otherwise {@code false} if it contains an infinite 064 * number of elements 065 * @see <a href="http://en.wikipedia.org/wiki/Countable_set">Countable 066 * set</a> (Wikipedia) 067 */ 068 public boolean isCountable(); 069 070 /** 071 * Answer {@code true} if this structure, <i>in principle</i>, can be 072 * reduced via element removal or expanded via element addition. Empty 073 * collections are, in principle, reducible, but <i>read-only</i> 074 * collections are neither reducible or expandable. 075 * 076 * @return {@code true} if this structure can be either 077 * {@link #isReducible() reduced} or {@link #isExpandable() 078 * expanded} 079 */ 080 public boolean isElastic(); 081 082 /** 083 * Answer {@code true} if this structure contains no elements. For 084 * {@link Text strings} this would indicate an empty string (no characters 085 * in an empty array). For scalars this would indicate an empty set, or a 086 * zero bit count, which would be the case of {@code null} values. Note 087 * that, although the {@code null} constant technically contains zero 088 * elements, its {@link String string} value evaluates to "null", which from 089 * a String perspective is not empty. 090 * 091 * @return {@code true} if this structure contains no elements 092 */ 093 public boolean isEmpty(); 094 095 /** 096 * @return {@code true} if this structure can be expanded via element 097 * insertion 098 */ 099 public boolean isExpandable(); 100 101 /** 102 * Answer {@code true} if <i>the elements of this structure</i> necessarily 103 * share a partial or total order between each other within the context of 104 * this structure. Ordering does not necessarily imply a simple sequencing 105 * between randomly selected elements, but rather a necessary sorting order 106 * between elements independent of the sets they are related by. A 107 * {@link SortedSet} is ordered, not merely because its elements are <i>de 108 * facto</i> sorted, but because the {@code SortedSet} defines a universe in 109 * which only sortable elements can exist and it defines a sorting function 110 * which places those elements in their sorted order at the time of 111 * iteration. An <a href="http://en.wikipedia.org/wiki/Order_theory">ordered 112 * set</a> has elements with values that are reflexive, antisymmetric, and 113 * transitive relative to each other. Necessarily empty sets are not 114 * considered ordered. 115 * 116 * @return {@code true} if the structure has either a partial or total order 117 * over its elements 118 * 119 * @see <a href="http://en.wikipedia.org/wiki/Order_theory">order theory</a> 120 * (Wikipedia) 121 */ 122 public boolean isOrdered(); 123 124 /** 125 * Answer {@code true} if this structure, <i>in principle</i>, can be 126 * reduced via element removal. Empty collections are, in principle, 127 * reducible, but <i>read-only</i> collections are not. 128 * 129 * @return {@code true} if this structure, <i>in principle</i>, can be 130 * reduced via element removal 131 */ 132 public boolean isReducible(); 133 134 /** 135 * @return {@code true} if the elements in this structure are, by definition 136 * of the structure's algebra, unique (e.g., {@link Set sets}) 137 */ 138 public boolean isUnique(); 139}