001package votorola.a.position; // Copyright 2013, Michael Allan. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Votorola Software"), to deal in the Votorola Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicence, and/or sell copies of the Votorola Software, and to permit persons to whom the Votorola Software is furnished to do so, subject to the following conditions: The preceding copyright notice and this permission notice shall be included in all copies or substantial portions of the Votorola Software. THE VOTOROLA SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE VOTOROLA SOFTWARE OR THE USE OR OTHER DEALINGS IN THE VOTOROLA SOFTWARE. 002 003import java.util.*; 004import votorola.a.*; 005import votorola.g.lang.*; 006 007 008/** A component pipe revision constructed for a specific {@linkplain DraftRevision draft 009 * revision path}. 010 */ 011public final @ThreadSafe class ComponentPipeRevision1 extends ComponentPipeRevision 012{ 013 014 015 /** Partially constructs a ComponentPipeRevision1 for {@linkplain #init(CoreRevision) 016 * init} to finish. 017 * 018 * @see #pageID() 019 * @param _pageName will be normalized for the {@linkplain #pageName() pageName}. 020 * @see #rev() 021 * @see #revLatest() 022 * @see #nominee() 023 * @see #person() 024 * @see #pollName() 025 */ 026 ComponentPipeRevision1( final PollwikiVS wiki, int _pageID, String _pageName, int _rev, 027 int _revLatest, String _nomineeName, String _personName, final String pollName ) 028 throws MalformedContent 029 { 030 super( wiki, _pageID, _pageName, _rev, _revLatest, _nomineeName, _personName, pollName ); 031 } 032 033 034 035 /** Finishes the construction of this ComponentPipeRevision1 and sets {@linkplain 036 * #isFullyConstructed() isFullyConstructed} true. 037 * 038 * @see #variant() 039 * 040 * @throws IllegalStateException if called a second time. 041 */ 042 public @ThreadRestricted("constructor") void init( CoreRevision _variant ) 043 { 044 if( isFullyConstructed ) throw new IllegalStateException(); 045 046 variant = _variant; 047 if( variant == null ) throw new NullPointerException(); // fail fast 048 049 isFullyConstructed = true; 050 } 051 052 053 054 /** @throws UnsupportedOperationException 055 */ 056 public void init( PollwikiVS _wiki, String _contextPersonName, 057 votorola.a.count.CountSource _countSource ) 058 { 059 throw new UnsupportedOperationException(); 060 } 061 062 063 064 // ------------------------------------------------------------------------------------ 065 066 067 068 /** The variant indicated by this component pipe, being either the candidate variant 069 * or the wild variant depending on the specific revision path for which this pipe 070 * was constructed. 071 */ 072 public CoreRevision variant() { return variant; } 073 074 075 private CoreRevision variant; // final when fully constructed, never null then 076 077 078 079 // - C o r e - R e v i s i o n -------------------------------------------------------- 080 081 082 public List<Integer> addDraftRevisionPath( final List<Integer> path ) 083 { 084 path.add( rev() ); 085 return variant.addDraftRevisionPath( path ); 086 } 087 088 089 090 public CoreRevision contextView( String _contextPersonName ) 091 { 092 return ComponentPipeRevision1.this; 093 } 094 095 096 097 public DraftRevision draft() { return variant.draft(); } 098 099 100 101 /** @see #init(CoreRevision) 102 */ 103 public boolean isFullyConstructed() { return isFullyConstructed; } 104 105 106 private boolean isFullyConstructed; 107 108 109}