add --shared
[pylucene.git] / lucene-java-3.4.0 / lucene / src / java / org / apache / lucene / util / fst / NoOutputs.java
1 package org.apache.lucene.util.fst;
2
3 /**
4  * Licensed to the Apache Software Foundation (ASF) under one or more
5  * contributor license agreements.  See the NOTICE file distributed with
6  * this work for additional information regarding copyright ownership.
7  * The ASF licenses this file to You under the Apache License, Version 2.0
8  * (the "License"); you may not use this file except in compliance with
9  * the License.  You may obtain a copy of the License at
10  *
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19
20 import org.apache.lucene.store.DataInput;
21 import org.apache.lucene.store.DataOutput;
22
23 /**
24  * Use this if you just want to build an FSA.
25  *
26  * @lucene.experimental
27  */
28
29 public final class NoOutputs extends Outputs<Object> {
30
31   static final Object NO_OUTPUT = new Object() {
32     // NodeHash calls hashCode for this output; we fix this
33     // so we get deterministic hashing.
34     @Override
35     public int hashCode() {
36       return 42;
37     }
38
39     @Override
40     public boolean equals(Object other) {
41       return other == this;
42     }
43   };
44
45   private static final NoOutputs singleton = new NoOutputs();
46
47   private NoOutputs() {
48   }
49
50   public static NoOutputs getSingleton() {
51     return singleton;
52   }
53
54   @Override
55   public Object common(Object output1, Object output2) {
56     assert output1 == NO_OUTPUT;
57     assert output2 == NO_OUTPUT;
58     return NO_OUTPUT;
59   }
60
61   @Override
62   public Object subtract(Object output, Object inc) {
63     assert output == NO_OUTPUT;
64     assert inc == NO_OUTPUT;
65     return NO_OUTPUT;
66   }
67
68   @Override
69   public Object add(Object prefix, Object output) {
70     assert prefix == NO_OUTPUT: "got " + prefix;
71     assert output == NO_OUTPUT;
72     return NO_OUTPUT;
73   }
74
75   @Override
76   public void write(Object prefix, DataOutput out) {
77     //assert false;
78   }
79
80   @Override
81   public Object read(DataInput in) {
82     //assert false;
83     //return null;
84     return NO_OUTPUT;
85   }
86
87   @Override
88   public Object getNoOutput() {
89     return NO_OUTPUT;
90   }
91
92   @Override
93   public String outputToString(Object output) {
94     return "";
95   }
96 }