index int64 0 0 | repo_id stringlengths 26 205 | file_path stringlengths 51 246 | content stringlengths 8 433k | __index_level_0__ int64 0 10k |
|---|---|---|---|---|
0 | Create_ds/zeno/src/main/java/com/netflix/zeno | Create_ds/zeno/src/main/java/com/netflix/zeno/json/JsonFrameworkSerializer.java | /*
*
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.netflix.zeno.json;
import com.netflix.zeno.serializer.FrameworkSerializer;
import com.netflix.zeno.serializer.NFTypeSerializer;
import com.netflix.zeno.serializer.SerializationFramework;
import com.netflix.zeno.util.PrimitiveObjectIdentifier;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.apache.commons.codec.binary.Base64;
/**
*
* @author tvaliulin
*
*/
public class JsonFrameworkSerializer extends FrameworkSerializer<JsonWriteGenericRecord> {
JsonFrameworkSerializer(SerializationFramework framework) {
super(framework);
}
@Override
public void serializePrimitive(JsonWriteGenericRecord rec, String fieldName, Object value) {
JsonWriteGenericRecord record = (JsonWriteGenericRecord) rec;
try {
if (value != null) {
if (value.getClass().isEnum()) {
value = ((Enum<?>) value).name();
}
}
record.getGenerator().writeObjectField(fieldName, value);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
@Override
public void serializeBytes(JsonWriteGenericRecord rec, String fieldName, byte[] value) {
String str = null;
if (value != null) {
byte encoded[] = Base64.encodeBase64(value, false);
str = new String(encoded, Charset.forName("UTF-8"));
}
serializePrimitive(rec, fieldName, str);
}
private static boolean isPrimitive(Class<?> type) {
return type.isEnum() || PrimitiveObjectIdentifier.isPrimitiveOrWrapper(type);
}
/*
* @Deprecated instead use serializeObject(HashGenericRecord rec, String fieldName, Object obj)
*
*/
@Deprecated
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public void serializeObject(JsonWriteGenericRecord record, String fieldName, String typeName, Object obj) {
try {
if (obj == null) {
record.getGenerator().writeObjectField(fieldName, null);
return;
}
if (isPrimitive(obj.getClass())) {
serializePrimitive(record, fieldName, obj);
return;
}
record.getGenerator().writeFieldName(fieldName);
record.getGenerator().writeStartObject();
NFTypeSerializer fieldSerializer = getSerializer(typeName);
JsonWriteGenericRecord fieldRecord = new JsonWriteGenericRecord(record.getGenerator());
fieldSerializer.serialize(obj, fieldRecord);
record.getGenerator().writeEndObject();
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
@Override
public void serializeObject(JsonWriteGenericRecord record, String fieldName, Object obj) {
serializeObject(record, fieldName, record.getObjectType(fieldName), obj);
}
@Override
public <T> void serializeList(JsonWriteGenericRecord rec, String fieldName, String typeName, Collection<T> obj) {
serializeCollection(rec, "list", typeName, obj);
}
@Override
public <T> void serializeSet(JsonWriteGenericRecord rec, String fieldName, String typeName, Set<T> obj) {
serializeCollection(rec, "set", typeName, obj);
}
@SuppressWarnings({ "rawtypes", "unchecked" })
private <T> void serializeCollection(JsonWriteGenericRecord record, String fieldName, String typeName, Collection<T> obj) {
try {
if (obj == null) {
record.getGenerator().writeObjectField(fieldName, null);
return;
}
record.getGenerator().writeArrayFieldStart(fieldName);
NFTypeSerializer elemSerializer = getSerializer(typeName);
JsonWriteGenericRecord elemRecord = new JsonWriteGenericRecord(record.getGenerator());
for (T t : obj) {
record.getGenerator().writeStartObject();
elemSerializer.serialize(t, elemRecord);
record.getGenerator().writeEndObject();
}
record.getGenerator().writeEndArray();
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
@Override
public <K, V> void serializeMap(JsonWriteGenericRecord record, String fieldName, String keyTypeName, String valueTypeName, Map<K, V> obj) {
try {
if (obj == null) {
record.getGenerator().writeObjectField(fieldName, null);
return;
}
record.getGenerator().writeFieldName("map");
record.getGenerator().writeStartArray();
for (Map.Entry<K, V> entry : sortedEntryList(obj)) {
record.getGenerator().writeStartObject();
serializeObject(record, "key", keyTypeName, entry.getKey());
serializeObject(record, "value", valueTypeName, entry.getValue());
record.getGenerator().writeEndObject();
}
record.getGenerator().writeEndArray();
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
// / Impose a consistent ordering over the map entries. This allows the
// diffs to match up better.
private <K, V> List<Map.Entry<K, V>> sortedEntryList(Map<K, V> obj) {
List<Map.Entry<K, V>> entryList = new ArrayList<Map.Entry<K, V>>(obj.entrySet());
Collections.sort(entryList, new Comparator<Map.Entry<K, V>>() {
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public int compare(Entry<K, V> o1, Entry<K, V> o2) {
K k1 = o1.getKey();
K k2 = o2.getKey();
if (k1 instanceof Comparable) {
return ((Comparable) k1).compareTo(k2);
}
return k1.hashCode() - k2.hashCode();
}
});
return entryList;
}
}
| 8,400 |
0 | Create_ds/zeno/src/main/java/com/netflix/zeno | Create_ds/zeno/src/main/java/com/netflix/zeno/json/JsonSerializationFramework.java | /*
*
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.netflix.zeno.json;
import java.io.IOException;
import java.io.StringWriter;
import java.util.Map;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.netflix.zeno.serializer.NFTypeSerializer;
import com.netflix.zeno.serializer.SerializationFramework;
import com.netflix.zeno.serializer.SerializerFactory;
import com.netflix.zeno.serializer.common.MapSerializer;
/**
*
* Serializes and deserializes JSON based on object instance contents.<p/>
*
* Usage is detailed in the <a href="https://github.com/Netflix/zeno/wiki">documentation</a>
* on the page <a href="https://github.com/Netflix/zeno/wiki/Creating-json-data">creating json data</a>.<p/>
*
* Please see JSONSerializationExample in the source folder src/examples/java for example usage.
*
* @author tvaliulin
*
*/
public class JsonSerializationFramework extends SerializationFramework {
public JsonSerializationFramework(SerializerFactory factory) {
super(factory);
this.frameworkSerializer = new JsonFrameworkSerializer(this);
this.frameworkDeserializer = new JsonFrameworkDeserializer(this);
}
public <T> String serializeAsJson(String type, T object) {
return serializeAsJson(type, object, true);
}
public <T> String serializeAsJson(String type, T object, boolean pretty) {
StringWriter writer = new StringWriter();
JsonWriteGenericRecord record = new JsonWriteGenericRecord(writer, pretty);
record.open();
getSerializer(type).serialize(object, record);
record.close();
writer.flush();
return writer.toString();
}
public <K, V> String serializeJsonMap(String keyType, String valueType, Map<K, V> map, boolean pretty) {
NFTypeSerializer<K> keySerializer = getSerializer(keyType);
NFTypeSerializer<V> valueSerializer = getSerializer(valueType);
MapSerializer<K, V> mapSerializer = new MapSerializer<K, V>(keySerializer, valueSerializer);
mapSerializer.setSerializationFramework(this);
StringWriter writer = new StringWriter();
JsonWriteGenericRecord record = new JsonWriteGenericRecord(writer, pretty);
record.open();
mapSerializer.serialize(map, record);
record.close();
writer.flush();
return writer.toString();
}
public <T> T deserializeJson(String type, String json) throws IOException {
ObjectMapper mapper = new ObjectMapper();
JsonNode node = mapper.readTree(json);
NFTypeSerializer<T> serializer = getSerializer(type);
JsonReadGenericRecord readRecord = new JsonReadGenericRecord(serializer.getFastBlobSchema(), node);
T object = serializer.deserialize(readRecord);
return object;
}
public <K, V> Map<K, V> deserializeJsonMap(String keyType, String valueType, String json) throws IOException {
NFTypeSerializer<K> keySerializer = getSerializer(keyType);
NFTypeSerializer<V> valueSerializer = getSerializer(valueType);
MapSerializer<K, V> mapSerializer = new MapSerializer<K, V>(keySerializer, valueSerializer);
mapSerializer.setSerializationFramework(this);
JsonNode node = new ObjectMapper().readTree(json);
JsonReadGenericRecord readRecord = new JsonReadGenericRecord(mapSerializer.getFastBlobSchema(), node);
return mapSerializer.deserialize(readRecord);
}
}
| 8,401 |
0 | Create_ds/zeno/src/main/java/com/netflix/zeno | Create_ds/zeno/src/main/java/com/netflix/zeno/json/JsonWriteGenericRecord.java | /*
*
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.netflix.zeno.json;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
import com.netflix.zeno.serializer.NFSerializationRecord;
import java.io.Writer;
/**
*
* @author tvaliulin
*
*/
public class JsonWriteGenericRecord extends NFSerializationRecord {
private static final JsonFactory s_jfactory = new JsonFactory();
private static final DefaultPrettyPrinter prettyPrinter = new DefaultPrettyPrinter();
private JsonGenerator jGenerator;
public JsonWriteGenericRecord(Writer writer, boolean pretty) {
this(writer);
if(pretty)
jGenerator.setPrettyPrinter(prettyPrinter);
}
public JsonWriteGenericRecord(Writer writer) {
try {
jGenerator = s_jfactory.createGenerator(writer);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
public JsonWriteGenericRecord(JsonGenerator jGenerator) {
this.jGenerator = jGenerator;
}
public void open() {
try {
jGenerator.writeStartObject();
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
public void close() {
close(true);
}
public void close(boolean closeGenerator) {
try {
jGenerator.writeEndObject();
if (closeGenerator) {
jGenerator.close();
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
public JsonGenerator getGenerator() {
return jGenerator;
}
}
| 8,402 |
0 | Create_ds/aegisthus/aegisthus-core/src/test/java/com/netflix/aegisthus | Create_ds/aegisthus/aegisthus-core/src/test/java/com/netflix/aegisthus/tools/AegisthusSerializerTest.java | package com.netflix.aegisthus.tools;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;
import java.util.Map;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.tngtech.java.junit.dataprovider.DataProvider;
import com.tngtech.java.junit.dataprovider.DataProviderRunner;
import com.tngtech.java.junit.dataprovider.UseDataProvider;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(DataProviderRunner.class)
public class AegisthusSerializerTest {
@Test
@Ignore
public void agent() throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(AegisthusSerializerTest.class.getResourceAsStream("/agent.json")));
String line = null;
StringBuilder file = new StringBuilder();
while ((line = br.readLine()) != null) {
file.append(line);
}
new AegisthusSerializer().deserialize(file.toString());
}
@Test
@UseDataProvider("json")
public void deserializeExpire(String value) throws IOException {
Map<String, Object> map = new AegisthusSerializer().deserialize(value);
Assert.assertEquals(AegisthusSerializer.serialize(map), value);
}
@DataProvider
public static Object[][] json() {
return new Object[][] { { "{\"556e6b6e6f776e3a3738383838\": {\"deletedAt\": -9223372036854775808, \"columns\": [[\"ticketId\",\"d115046000bd11e1b27112313925158b\",1319735105450,\"e\",604800,1320339905]]}}" },
{ "{\"556e6b6e6f776e3a3738383838\": {\"deletedAt\": -9223372036854775808, \"columns\": [[\"\\\\N\",\"d115046000bd11e1b27112313925158b\",1319735105450,\"e\",604800,1320339905]]}}" },
{ "{\"556e6b6e6f776e3a3738383838\": {\"deletedAt\": -9223372036854775808, \"columns\": [[\"ticketId\",\"d115046000bd11e1b27112313925158b\",1319735105450,\"c\",604800]]}}" } };
}
private String s(Object obj) {
return obj.toString();
}
@SuppressWarnings("rawtypes")
@Test
public void serialize() throws IOException {
String value = "{\"uid\": {\"deletedAt\": 10, \"columns\": [[\"cell\",\"00000002\",1312400480243000], [\"enabled\",\"59\",1312400475129004], [\"newcolumn\",\"59\",1312400533649004]]}}";
Map<String, Object> map = new AegisthusSerializer().deserialize(value);
Assert.assertEquals(s(map.get(AegisthusSerializer.KEY)), "uid");
Assert.assertEquals(map.get(AegisthusSerializer.DELETEDAT), 10L);
Assert.assertEquals(s(((List) map.get("enabled")).get(1)), "59");
Assert.assertEquals(AegisthusSerializer.serialize(map), value);
}
@Test
@UseDataProvider("values")
public void serializeColumns(List<Object> values, String exp) {
Map<String, Object> map = Maps.newHashMap();
map.put(values.get(0).toString(), values);
StringBuilder sb = new StringBuilder();
AegisthusSerializer.serializeColumns(sb, map);
Assert.assertEquals(sb.toString(), exp);
}
@DataProvider
public static Object[][] values() {
Object[][] ret = new Object[2][2];
List<Object> values = Lists.newArrayList();
values.add("\\N");
values.add("");
values.add(1);
ret[0][0] = values;
ret[0][1] = "[\"\\\\N\",\"\",1]";
values = Lists.newArrayList();
values.add("\\\\N");
values.add("");
values.add(1);
ret[1][0] = values;
ret[1][1] = "[\"\\\\\\\\N\",\"\",1]";
return ret;
}
}
| 8,403 |
0 | Create_ds/aegisthus/aegisthus-core/src/main/java/org/xerial | Create_ds/aegisthus/aegisthus-core/src/main/java/org/xerial/snappy/SnappyInputStream2.java | /*--------------------------------------------------------------------------
* Copyright 2011 Taro L. Saito
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*--------------------------------------------------------------------------*/
//--------------------------------------
// XerialJ
//
// SnappyInputStream.java
// Since: 2011/03/31 20:14:56
//
// $URL$
// $Author$
//--------------------------------------
package org.xerial.snappy;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
/**
* This is included because a patch I put in upstream isn't installed on EMR...
*/
/**
* A stream filter for reading data compressed by {@link SnappyOutputStream}.
*
*
* @author leo
*
*/
public class SnappyInputStream2 extends InputStream
{
private boolean finishedReading = false;
protected final InputStream in;
private byte[] compressed;
private byte[] uncompressed;
private int uncompressedCursor = 0;
private int uncompressedLimit = 0;
private byte[] chunkSizeBuf = new byte[4];
/**
* Create a filter for reading compressed data as a uncompressed stream
*
* @param input
* @throws IOException
*/
public SnappyInputStream2(InputStream input) throws IOException {
this.in = input;
readHeader();
}
/**
* Close the stream
*/
/* (non-Javadoc)
* @see java.io.InputStream#close()
*/
@Override
public void close() throws IOException {
compressed = null;
uncompressed = null;
if (in != null)
in.close();
}
protected void readHeader() throws IOException {
byte[] header = new byte[SnappyCodec.headerSize()];
int readBytes = 0;
while (readBytes < header.length) {
int ret = in.read(header, readBytes, header.length - readBytes);
if (ret == -1)
break;
readBytes += ret;
}
// Quick test of the header
if (readBytes < header.length || header[0] != SnappyCodec.MAGIC_HEADER[0]) {
// do the default uncompression
readFully(header, readBytes);
return;
}
SnappyCodec codec = SnappyCodec.readHeader(new ByteArrayInputStream(header));
if (codec.isValidMagicHeader()) {
// The input data is compressed by SnappyOutputStream
if (codec.version < SnappyCodec.MINIMUM_COMPATIBLE_VERSION) {
throw new IOException(String.format(
"compressed with imcompatible codec version %d. At least version %d is required",
codec.version, SnappyCodec.MINIMUM_COMPATIBLE_VERSION));
}
}
else {
// (probably) compressed by Snappy.compress(byte[])
readFully(header, readBytes);
return;
}
}
protected void readFully(byte[] fragment, int fragmentLength) throws IOException {
// read the entire input data to the buffer
compressed = new byte[Math.max(8 * 1024, fragmentLength)]; // 8K
System.arraycopy(fragment, 0, compressed, 0, fragmentLength);
int cursor = fragmentLength;
for (int readBytes = 0; (readBytes = in.read(compressed, cursor, compressed.length - cursor)) != -1;) {
cursor += readBytes;
if (cursor >= compressed.length) {
byte[] newBuf = new byte[(compressed.length * 2)];
System.arraycopy(compressed, 0, newBuf, 0, compressed.length);
compressed = newBuf;
}
}
finishedReading = true;
// Uncompress
int uncompressedLength = Snappy.uncompressedLength(compressed, 0, cursor);
uncompressed = new byte[uncompressedLength];
Snappy.uncompress(compressed, 0, cursor, uncompressed, 0);
this.uncompressedCursor = 0;
this.uncompressedLimit = uncompressedLength;
}
/**
* Reads up to len bytes of data from the input stream into an array of
* bytes.
*/
/* (non-Javadoc)
* @see java.io.InputStream#read(byte[], int, int)
*/
@Override
public int read(byte[] b, int off, int len) throws IOException {
return rawRead(b, off, len);
}
/**
* Read uncompressed data into the specified array
*
* @param array
* @param byteOffset
* @param byteLength
* @return written bytes
* @throws IOException
*/
public int rawRead(Object array, int byteOffset, int byteLength) throws IOException {
int writtenBytes = 0;
for (; writtenBytes < byteLength;) {
if (uncompressedCursor >= uncompressedLimit) {
if (hasNextChunk())
continue;
else {
return writtenBytes == 0 ? -1 : writtenBytes;
}
}
int bytesToWrite = Math.min(uncompressedLimit - uncompressedCursor, byteLength - writtenBytes);
Snappy.arrayCopy(uncompressed, uncompressedCursor, bytesToWrite, array, byteOffset + writtenBytes);
writtenBytes += bytesToWrite;
uncompressedCursor += bytesToWrite;
}
return writtenBytes;
}
/**
* Read long array from the stream
*
* @param d
* input
* @param off
* offset
* @param len
* the number of long elements to read
* @return the total number of bytes read into the buffer, or -1 if there is
* no more data because the end of the stream has been reached.
* @throws IOException
*/
public int read(long[] d, int off, int len) throws IOException {
return rawRead(d, off * 8, len * 8);
}
/**
* Read long array from the stream
*
* @param d
* @return the total number of bytes read into the buffer, or -1 if there is
* no more data because the end of the stream has been reached.
* @throws IOException
*/
public int read(long[] d) throws IOException {
return read(d, 0, d.length);
}
/**
* Read double array from the stream
*
* @param d
* input
* @param off
* offset
* @param len
* the number of double elements to read
* @return the total number of bytes read into the buffer, or -1 if there is
* no more data because the end of the stream has been reached.
* @throws IOException
*/
public int read(double[] d, int off, int len) throws IOException {
return rawRead(d, off * 8, len * 8);
}
/**
* Read double array from the stream
*
* @param d
* @return the total number of bytes read into the buffer, or -1 if there is
* no more data because the end of the stream has been reached.
* @throws IOException
*/
public int read(double[] d) throws IOException {
return read(d, 0, d.length);
}
/**
* Read int array from the stream
*
* @param d
* @return the total number of bytes read into the buffer, or -1 if there is
* no more data because the end of the stream has been reached.
* @throws IOException
*/
public int read(int[] d) throws IOException {
return read(d, 0, d.length);
}
/**
* Read int array from the stream
*
* @param d
* input
* @param off
* offset
* @param len
* the number of int elements to read
* @return the total number of bytes read into the buffer, or -1 if there is
* no more data because the end of the stream has been reached.
* @throws IOException
*/
public int read(int[] d, int off, int len) throws IOException {
return rawRead(d, off * 4, len * 4);
}
/**
* Read float array from the stream
*
* @param d
* input
* @param off
* offset
* @param len
* the number of float elements to read
* @return the total number of bytes read into the buffer, or -1 if there is
* no more data because the end of the stream has been reached.
* @throws IOException
*/
public int read(float[] d, int off, int len) throws IOException {
return rawRead(d, off * 4, len * 4);
}
/**
* Read float array from the stream
*
* @param d
* @return the total number of bytes read into the buffer, or -1 if there is
* no more data because the end of the stream has been reached.
* @throws IOException
*/
public int read(float[] d) throws IOException {
return read(d, 0, d.length);
}
/**
* Read short array from the stream
*
* @param d
* input
* @param off
* offset
* @param len
* the number of short elements to read
* @return the total number of bytes read into the buffer, or -1 if there is
* no more data because the end of the stream has been reached.
* @throws IOException
*/
public int read(short[] d, int off, int len) throws IOException {
return rawRead(d, off * 2, len * 2);
}
/**
* Read short array from the stream
*
* @param d
* @return the total number of bytes read into the buffer, or -1 if there is
* no more data because the end of the stream has been reached.
* @throws IOException
*/
public int read(short[] d) throws IOException {
return read(d, 0, d.length);
}
protected boolean hasNextChunk() throws IOException {
if (finishedReading)
return false;
uncompressedCursor = 0;
uncompressedLimit = 0;
int readBytes = 0;
while (readBytes < 4) {
int ret = in.read(chunkSizeBuf, readBytes, 4 - readBytes);
if (ret == -1) {
finishedReading = true;
return false;
}
readBytes += ret;
}
int chunkSize = SnappyOutputStream.readInt(chunkSizeBuf, 0);
// extend the compressed data buffer size
if (compressed == null || chunkSize > compressed.length) {
compressed = new byte[chunkSize];
}
readBytes = 0;
while (readBytes < chunkSize) {
int ret = in.read(compressed, readBytes, chunkSize - readBytes);
if (ret == -1)
break;
readBytes += ret;
}
if (readBytes < chunkSize) {
throw new IOException("failed to read chunk");
}
try {
int uncompressedLength = Snappy.uncompressedLength(compressed, 0, chunkSize);
if (uncompressed == null || uncompressedLength > uncompressed.length) {
uncompressed = new byte[uncompressedLength];
}
int actualUncompressedLength = Snappy.uncompress(compressed, 0, chunkSize, uncompressed, 0);
if (uncompressedLength != actualUncompressedLength) {
throw new IOException("invalid uncompressed byte size");
}
uncompressedLimit = actualUncompressedLength;
}
catch (IOException e) {
throw new IOException("failed to uncompress the chunk: " + e.getMessage());
}
return true;
}
/**
* Reads the next byte of uncompressed data from the input stream. The value
* byte is returned as an int in the range 0 to 255. If no byte is available
* because the end of the stream has been reached, the value -1 is returned.
* This method blocks until input data is available, the end of the stream
* is detected, or an exception is thrown.
*/
/* (non-Javadoc)
* @see java.io.InputStream#read()
*/
@Override
public int read() throws IOException {
if (uncompressedCursor < uncompressedLimit) {
return uncompressed[uncompressedCursor++] & 0xFF;
}
else {
if (hasNextChunk())
return read();
else
return -1;
}
}
} | 8,404 |
0 | Create_ds/aegisthus/aegisthus-core/src/main/java/com/netflix/aegisthus | Create_ds/aegisthus/aegisthus-core/src/main/java/com/netflix/aegisthus/tools/DirectoryWalker.java | /**
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.aegisthus.tools;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.regex.Pattern;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.PathFilter;
import com.google.common.collect.Lists;
/**
* A small tool for recursing directories in Hadoop.
*/
public class DirectoryWalker implements Cloneable {
private static class Cache implements Runnable {
public static Cache with(DirectoryWalker dw) {
return new Cache(dw);
}
private DirectoryWalker dw;
private List<PartitionInfo> files;
private PartitionInfo partitionInfo;
protected Cache(DirectoryWalker dw) {
this.dw = dw;
}
public Cache cache(PartitionInfo partitionInfo) {
this.partitionInfo = partitionInfo;
return this;
}
public Cache into(List<PartitionInfo> files) {
this.files = files;
return this;
}
public void run() {
try {
List<PartitionInfo> files = null;
if (partitionInfo.getStatus(dw.conf) != null) {
files = Lists.newArrayList(dw.add(partitionInfo).partitionInfo());
if (files.size() > 0) {
LOG.info(String.format("%s : % 4d file(s)", partitionInfo
.getStatus(dw.conf)
.getPath()
.toUri()
.toString(), files.size()));
}
}
try {
dw.lock.lock();
this.files.addAll(files);
} finally {
dw.lock.unlock();
}
} catch (IOException e) {
LOG.warn(String.format("%s : doesn't exist", partitionInfo
.getStatus(dw.conf)
.getPath()
.toUri()
.toString()));
throw new RuntimeException(e);
}
}
}
public static class PartitionInfo {
private String location;
private String partitionName;
private FileStatus status;
public PartitionInfo(FileStatus status) {
this.status = status;
}
public PartitionInfo(String partitionName) {
this.partitionName = partitionName;
}
public PartitionInfo(String partitionName, FileStatus status) {
this.partitionName = partitionName;
this.status = status;
}
public PartitionInfo(String partitionName, String location) {
this.partitionName = partitionName;
this.setLocation(location);
}
public String getLocation() {
return location;
}
public String getPartitionName() {
return partitionName;
}
public FileStatus getStatus(Configuration conf) {
if (status == null && location != null) {
Path path = new Path(location);
try {
FileSystem fs = path.getFileSystem(conf);
status = fs.getFileStatus(path);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return status;
}
public void setLocation(String location) {
this.location = location;
}
public void setPartitionName(String partitionName) {
this.partitionName = partitionName;
}
public void setStatus(FileStatus status) {
this.status = status;
}
}
public static final Pattern batch = Pattern.compile("batch_?id=[0-9]+/?$");
public static final PathFilter HIDDEN_FILE_FILTER = new PathFilter() {
public boolean accept(Path p) {
String name = p.getName();
return !name.startsWith("_") && !name.startsWith(".");
}
};
private static final Log LOG = LogFactory.getLog(DirectoryWalker.class);
private static FileStatus[] filterBatch(FileStatus[] files, boolean batched) {
if (batched && files.length > 0 && batch.matcher(files[0].getPath().toString()).find()) {
FileStatus first = files[0];
FileStatus last = files[files.length - 1];
if (first.getPath().toUri().toString().compareTo(last.getPath().toUri().toString()) > 0) {
return new FileStatus[] { first };
}
return new FileStatus[] { last };
}
return files;
}
public static DirectoryWalker with(Configuration conf) {
return new DirectoryWalker(conf);
}
private String base = null;
private boolean batched = false;
private final Configuration conf;
private ExecutorService es = null;
private List<PartitionInfo> files = Lists.newArrayList();
public ChainedPathFilter filter = new ChainedPathFilter();
private FileSystem fs;
protected Lock lock = new ReentrantLock();
private boolean manifest = false;
private boolean omitHidden = true;
private boolean onlyOne = false;
private boolean recursive = true;
private boolean stopAdding = false;
private boolean threaded = false;
protected DirectoryWalker(Configuration conf) {
this.conf = conf;
}
public DirectoryWalker add(FileStatus status) throws IOException {
this.fs = status.getPath().getFileSystem(conf);
this.base = status.getPath().toUri().toString();
if (!base.endsWith("/")) {
base = base + "/";
}
process(new PartitionInfo(status));
return this;
}
public DirectoryWalker add(PartitionInfo partitionInfo) throws IOException {
this.base = partitionInfo.getStatus(conf).getPath().toUri().toString();
if (!base.endsWith("/")) {
base = base + "/";
}
this.fs = partitionInfo.getStatus(conf).getPath().getFileSystem(conf);
process(partitionInfo);
return this;
}
public DirectoryWalker add(Path path) throws IOException {
this.base = path.toUri().toString();
if (!base.endsWith("/")) {
base = base + "/";
}
this.fs = path.getFileSystem(conf);
process(new PartitionInfo(fs.getFileStatus(path)));
return this;
}
public DirectoryWalker add(String location) throws IOException {
if (stopAdding) {
return this;
}
Path path = new Path(location);
fs = path.getFileSystem(conf);
this.base = location;
if (!base.endsWith("/")) {
base = base + "/";
}
if (fs.exists(path)) {
FileStatus status = fs.getFileStatus(path);
process(new PartitionInfo(status));
} else {
LOG.warn(String.format("%s does not exist", location));
}
return this;
}
public DirectoryWalker addAll(List<String> locations) throws IOException {
if (stopAdding) {
return this;
}
for (String location : locations) {
if (threaded) {
// We do the thread here to get around having to do a
// getFileStatus on each string in the main thread,
// which is slow for a large number of partitions on s3.
try {
es.submit(Cache
.with((DirectoryWalker) this.clone())
.into(this.files)
.cache(new PartitionInfo(null, location)));
} catch (CloneNotSupportedException e) {
}
} else {
add(location);
}
}
return this;
}
public DirectoryWalker addAllPartitions(List<PartitionInfo> partitions) throws IOException {
if (stopAdding) {
return this;
}
for (PartitionInfo partitionInfo : partitions) {
process(partitionInfo);
}
return this;
}
public DirectoryWalker addAllStatuses(List<FileStatus> locations) throws IOException {
if (stopAdding) {
return this;
}
for (FileStatus status : locations) {
process(new PartitionInfo(status));
}
return this;
}
private void awaitTermination() {
if (threaded && !es.isShutdown()) {
es.shutdown();
try {
es.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS);
} catch (InterruptedException e) {
}
}
}
public DirectoryWalker batched(boolean batched) {
this.batched = batched;
return this;
}
protected boolean cache(PartitionInfo partitionInfo) throws IOException {
FileStatus status = partitionInfo.getStatus(conf);
if (manifest && status.isDir()) {
Path manifest = new Path(status.getPath(), "_manifest/_manifest");
if (fs.exists(manifest)) {
LOG.info(String.format("Using manifest for partition %s", partitionInfo.partitionName));
BufferedReader br = new BufferedReader(new InputStreamReader(fs.open(manifest)));
String file;
while ((file = br.readLine()) != null) {
files.add(new PartitionInfo(partitionInfo.getPartitionName(), fs.getFileStatus(new Path(file))));
}
return true;
}
}
if (status.isDir()) {
if (filter.accept(status.getPath())) {
for (FileStatus file : filterBatch(fs.listStatus(status.getPath()), batched)) {
if (!omitHidden || HIDDEN_FILE_FILTER.accept(file.getPath())) {
PartitionInfo child = new PartitionInfo(partitionInfo.getPartitionName(), file);
if ((recursive || !file.isDir()) && !cache(child)) {
return false;
}
}
}
}
} else {
files.add(partitionInfo);
stopAdding = onlyOne;
return !onlyOne;
}
return true;
}
public DirectoryWalker clearFilter() {
filter.clear();
return this;
}
@Override
protected Object clone() throws CloneNotSupportedException {
DirectoryWalker dw = DirectoryWalker.with(conf);
dw.onlyOne = this.onlyOne;
dw.omitHidden = this.omitHidden;
dw.stopAdding = this.stopAdding;
dw.batched = this.batched;
dw.recursive = this.recursive;
dw.filter = this.filter;
dw.lock = this.lock;
dw.manifest = this.manifest;
return dw;
}
public DirectoryWalker filter(PathFilter filter) {
this.filter.add(filter);
return this;
}
public DirectoryWalker manifest(boolean manifest) {
this.manifest = manifest;
return this;
}
public DirectoryWalker omitHidden() {
omitHidden = true;
return this;
}
public DirectoryWalker omitHidden(boolean omit) {
omitHidden = omit;
return this;
}
/**
* This will stop the walk of the directory when we find a single file that
* matches the filter
*/
public DirectoryWalker onlyOne() {
onlyOne = true;
return this;
}
public DirectoryWalker onlyOne(boolean onlyOne) {
this.onlyOne = onlyOne;
return this;
}
public List<PartitionInfo> partitionInfo() {
awaitTermination();
return files;
}
public Iterable<Path> paths() {
awaitTermination();
List<Path> paths = Lists.newArrayList();
for (PartitionInfo partitionInfo : files) {
paths.add(partitionInfo.getStatus(conf).getPath());
}
return paths;
}
public Iterable<String> pathsString() {
awaitTermination();
List<String> paths = Lists.newArrayList();
for (PartitionInfo partitionInfo : files) {
paths.add(partitionInfo.getStatus(conf).getPath().toUri().getPath());
}
return paths;
}
protected boolean process(PartitionInfo partitionInfo) throws IOException {
if (threaded) {
try {
es.submit(Cache.with((DirectoryWalker) this.clone()).into(this.files).cache(partitionInfo));
} catch (CloneNotSupportedException e) {
}
return true;
} else {
return cache(partitionInfo);
}
}
public DirectoryWalker recursive(boolean recursive) {
this.recursive = recursive;
return this;
}
/**
* Example:<br/>
* DirectoryWalker.with(conf).add("/my/path").relativePathStrings();<br/>
* will return the relative paths of all the files under /my/path
*
* @return the relative paths in a directory.
*/
public Iterable<String> relativePathStrings() {
awaitTermination();
if (base == null) {
throw new RuntimeException("relativePathStrings will only work with a single base using add");
}
List<String> paths = Lists.newArrayList();
for (PartitionInfo partitionInfo : files) {
FileStatus status = partitionInfo.getStatus(conf);
String path = status.getPath().toUri().toString();
if (!path.contains(base)) {
throw new RuntimeException("relativePathStrings will only work with a single base using add");
}
LOG.info(path);
LOG.info(base);
path = path.substring(path.indexOf(base) + base.length());
try {
path = URLDecoder.decode(path, "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
LOG.info(path);
paths.add(path);
}
return paths;
}
public Iterable<FileStatus> statuses() {
awaitTermination();
List<FileStatus> statuses = Lists.newArrayList();
for (PartitionInfo partitionInfo : files) {
statuses.add(partitionInfo.getStatus(conf));
}
return statuses;
}
public DirectoryWalker threaded() {
return threaded(25);
}
public DirectoryWalker threaded(int threads) {
this.es = Executors.newFixedThreadPool(threads);
this.threaded = true;
return this;
}
}
| 8,405 |
0 | Create_ds/aegisthus/aegisthus-core/src/main/java/com/netflix/aegisthus | Create_ds/aegisthus/aegisthus-core/src/main/java/com/netflix/aegisthus/tools/AegisthusSerializer.java | /**
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.aegisthus.tools;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.apache.pig.data.DataByteArray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
/**
* Read and write Aegisthus Json format.
*/
public class AegisthusSerializer {
private static final Logger LOG = LoggerFactory.getLogger(AegisthusSerializer.class);
public static String DELETEDAT = "DELETEDAT";
public static String KEY = "$$KEY$$";
protected static JsonFactory jsonFactory = new JsonFactory();
static {
jsonFactory.configure(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true);
}
public Object type(String value) {
return value;
}
public Map<String, Object> deserialize(String data) throws IOException {
try {
Map<String, Object> map = new LinkedHashMap<String, Object>();
JsonParser jp = jsonFactory.createJsonParser(data);
jp.nextToken(); // Object
jp.nextToken(); // key
map.put(KEY, new DataByteArray(jp.getCurrentName().getBytes()));
jp.nextToken(); // object
while (jp.nextToken() != JsonToken.END_OBJECT) {
String field = jp.getCurrentName();
if (DELETEDAT.equals(field.toUpperCase())) {
jp.nextToken();
map.put(DELETEDAT, jp.getLongValue());
} else {
jp.nextToken();
while (jp.nextToken() != JsonToken.END_ARRAY) {
List<Object> cols = new ArrayList<Object>();
jp.nextToken();
String name = jp.getText();
cols.add(name);
jp.nextToken();
cols.add(new DataByteArray(jp.getText().getBytes()));
jp.nextToken();
cols.add(jp.getLongValue());
if (jp.nextToken() != JsonToken.END_ARRAY) {
String status = jp.getText();
cols.add(status);
if ("e".equals(status)) {
jp.nextToken();
cols.add(jp.getLongValue());
jp.nextToken();
cols.add(jp.getLongValue());
} else if ("c".equals(status)) {
jp.nextToken();
cols.add(jp.getLongValue());
}
jp.nextToken();
}
map.put(name, cols);
}
}
}
return map;
} catch (IOException e) {
LOG.error(data);
throw e;
}
}
protected static void insertKey(StringBuilder sb, Object value) {
sb.append("\"");
sb.append(value);
sb.append("\": ");
}
protected static void serializeColumns(StringBuilder sb, Map<String, Object> columns) {
int count = 0;
for (Map.Entry<String, Object> e : columns.entrySet()) {
if (count++ > 0) {
sb.append(", ");
}
@SuppressWarnings("unchecked")
List<Object> list = (List<Object>) e.getValue();
sb.append("[");
sb.append("\"").append(((String) list.get(0)).replace("\\", "\\\\").replace("\"", "\\\"")).append("\"").append(",");
sb.append("\"").append(list.get(1)).append("\"").append(",");
sb.append(list.get(2));
if (list.size() > 3) {
sb.append(",").append("\"").append(list.get(3)).append("\"");
}
for (int i = 4; i < list.size(); i++) {
sb.append(",").append(list.get(i));
}
sb.append("]");
}
}
public static String serialize(Map<String, Object> data) {
StringBuilder str = new StringBuilder();
str.append("{");
insertKey(str, data.remove(KEY));
str.append("{");
insertKey(str, "deletedAt");
str.append(data.remove(DELETEDAT));
str.append(", ");
insertKey(str, "columns");
str.append("[");
serializeColumns(str, data);
str.append("]");
str.append("}}");
return str.toString();
}
}
| 8,406 |
0 | Create_ds/aegisthus/aegisthus-core/src/main/java/com/netflix/aegisthus | Create_ds/aegisthus/aegisthus-core/src/main/java/com/netflix/aegisthus/tools/Utils.java | /**
* Copyright 2014 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.aegisthus.tools;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapreduce.TaskAttemptContext;
import org.xerial.snappy.SnappyInputStream2;
public class Utils {
private static final Log LOG = LogFactory.getLog(Utils.class);
public static void copy(Path from, Path to, boolean snappy, Configuration conf) throws IOException {
FileSystem fromFs = from.getFileSystem(conf);
FileSystem toFs = to.getFileSystem(conf);
InputStream in = fromFs.open(from);
OutputStream out = toFs.create(to, false);
try {
if (snappy) {
in = new SnappyInputStream2(in);
}
byte[] buffer = new byte[65536];
int bytesRead;
while ((bytesRead = in.read(buffer)) >= 0) {
if (bytesRead > 0) {
out.write(buffer, 0, bytesRead);
}
}
} finally {
in.close();
out.close();
}
}
public static void copy(Path from, Path to, boolean snappy, TaskAttemptContext ctx) throws IOException {
FileSystem fromFs = from.getFileSystem(ctx.getConfiguration());
FileSystem toFs = to.getFileSystem(ctx.getConfiguration());
if (!to.isAbsolute()) {
to = new Path(ctx.getConfiguration().get("mapred.working.dir"), to);
}
if (!snappy && onSameHdfs(ctx.getConfiguration(), from, to)) {
LOG.info(String.format("renaming %s to %s", from, to));
toFs.mkdirs(to.getParent());
toFs.rename(from, to);
return;
}
InputStream in = fromFs.open(from);
OutputStream out = toFs.create(to, false);
try {
if (snappy) {
in = new SnappyInputStream2(in);
}
byte[] buffer = new byte[65536];
int bytesRead;
int count = 0;
while ((bytesRead = in.read(buffer)) >= 0) {
if (bytesRead > 0) {
out.write(buffer, 0, bytesRead);
}
if (count++ % 50 == 0) {
ctx.progress();
}
}
} finally {
in.close();
out.close();
}
}
public static void copy(Path relative, Path fromDir, Path toDir, TaskAttemptContext ctx) throws IOException {
Path from = new Path(fromDir, relative);
Path to = new Path(toDir, relative);
copy(from, to, false, ctx);
}
public static boolean delete(Configuration config, Path path, boolean recursive) throws IOException {
FileSystem fs = path.getFileSystem(config);
return fs.delete(path, recursive);
}
protected static boolean onSameHdfs(Configuration conf, Path a, Path b) throws IOException {
FileSystem aFs = a.getFileSystem(conf);
FileSystem bFs = b.getFileSystem(conf);
return (aFs.equals(bFs));
}
}
| 8,407 |
0 | Create_ds/aegisthus/aegisthus-core/src/main/java/com/netflix/aegisthus | Create_ds/aegisthus/aegisthus-core/src/main/java/com/netflix/aegisthus/tools/ChainedPathFilter.java | /**
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.aegisthus.tools;
import java.util.List;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.PathFilter;
import com.google.common.collect.Lists;
public class ChainedPathFilter implements PathFilter {
List<PathFilter> pfs = Lists.newArrayList();
@Override
public boolean accept(Path path) {
for (PathFilter pf : pfs) {
if (!pf.accept(path)) {
return false;
}
}
return true;
}
public void add(PathFilter pf) {
pfs.add(pf);
}
public void clear() {
pfs.clear();
}
}
| 8,408 |
0 | Create_ds/aegisthus/aegisthus-core/src/main/java/com/netflix/aegisthus | Create_ds/aegisthus/aegisthus-core/src/main/java/com/netflix/aegisthus/tools/StorageHelper.java | /**
* Copyright 2014 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.aegisthus.tools;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapreduce.TaskAttemptContext;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
public class StorageHelper {
public static String CFG_BASE_TEMP_DIR = "storagehelper.base.temp.dir";
public static String CFG_OUTPUT_DIR = "storagehelper.output.dir";
public static String CFG_STORAGE_DEBUG = "storagehelper.debug";
private static final Log LOG = LogFactory.getLog(StorageHelper.class);;
private Configuration config = null;
private TaskAttemptContext ctx = null;
private boolean debug = false;
private Set<String> jobFiles = null;
private Set<String> taskFiles = null;
public StorageHelper(Configuration config) {
this.config = config;
debug = config.getBoolean(CFG_STORAGE_DEBUG, false);
}
public StorageHelper(TaskAttemptContext ctx) {
this.ctx = ctx;
this.config = ctx.getConfiguration();
debug = config.getBoolean(CFG_STORAGE_DEBUG, false);
}
private Path commitPath() {
String base = getBaseTempLocation();
return new Path(base, "commits");
}
private Path commitPath(int taskId) {
Path commits = commitPath();
return new Path(commits, String.format("commit-%d", taskId));
}
public void copyToTemp(String file, String prefix, boolean snappy) throws IOException {
String target = getBaseTaskAttemptTempLocation();
Path targetPath = new Path(target, prefix);
Path filePath = new Path(file);
Path fullPath = new Path(targetPath, filePath.getName());
String log = String.format("copying %s to %s", file, fullPath.toUri().toString());
LOG.info(log);
ctx.setStatus(log);
Utils.copy(new Path(file), fullPath, snappy, ctx);
}
public void copyToTemp(String file, boolean snappy) throws IOException {
String target = getBaseTaskAttemptTempLocation();
Path targetPath = new Path(target);
Path filePath = new Path(file);
Path fullPath = new Path(targetPath, filePath.getName());
String log = String.format("copying %s to %s", file, fullPath.toUri().toString());
LOG.info(log);
ctx.setStatus(log);
Utils.copy(filePath, fullPath, snappy, ctx);
}
public void deleteBaseTempLocation() throws IOException {
String base = getBaseTempLocation();
Path path = new Path(base);
FileSystem fs = path.getFileSystem(config);
LOG.info(String.format("deleting: %s", base));
fs.delete(path, true);
}
public void deleteCommitted() throws IOException {
for (String file : getCommittedFiles()) {
LOG.info(String.format("deleting: %s", file));
Utils.delete(config, new Path(file), false);
}
}
private int getAttemptId() throws IOException {
if (ctx == null) {
throw new IOException("Not running in a TaskAttemptContext");
}
return ctx.getTaskAttemptID().getId();
}
public String getBaseTaskAttemptTempLocation() throws IOException {
int taskId = getTaskId();
int attemptId = getAttemptId();
String base = getBaseTempLocation();
return String.format("%s/%d-%d", base, taskId, attemptId);
}
/**
* This method has a side effect of setting values in the config for the
* job.
*/
public String getBaseTempLocation() {
String base = config.get(CFG_BASE_TEMP_DIR);
if (base == null) {
base = String.format("%s/%s", "/tmp", UUID.randomUUID());
config.set(CFG_BASE_TEMP_DIR, base);
}
return base;
}
public Set<String> getCommittedFiles() throws IOException {
if (jobFiles == null) {
List<Path> logs = Lists.newArrayList(DirectoryWalker.with(config).add(commitPath()).paths());
jobFiles = readCommitLogs(logs);
}
return jobFiles;
}
public Set<String> getCommittedFiles(int taskId) throws IOException {
if (taskFiles == null) {
List<Path> logs = Lists.newArrayList();
logs.add(commitPath(taskId));
taskFiles = readCommitLogs(logs);
}
return taskFiles;
}
public List<String> getCommittedFolderList() throws IOException {
Set<String> folders = Sets.newHashSet();
Set<String> files = getCommittedFiles();
for (String file : files) {
folders.add(file.replaceAll("/[^/]+$", ""));
}
return Lists.newArrayList(folders);
}
public Path getFinalPath() throws IOException {
if (config.get(CFG_OUTPUT_DIR) == null) {
throw new IOException(String.format("%s cannot be null", CFG_OUTPUT_DIR));
}
return new Path(config.get(CFG_OUTPUT_DIR));
}
private int getTaskId() throws IOException {
if (ctx == null) {
throw new IOException("Not running in a TaskAttemptContext");
}
return ctx.getTaskAttemptID().getTaskID().getId();
}
/**
* This method will check if this file was previously committed by this
* task.
*/
public boolean isFileMine(int taskId, String file) throws IOException {
return getCommittedFiles(taskId).contains(file);
}
public void logCommit(String file) throws IOException {
Path log = commitPath(getTaskId());
if (debug) {
LOG.info(String.format("logging (%s) to commit log (%s)", file, log.toUri().toString()));
}
FileSystem fs = log.getFileSystem(config);
DataOutputStream os = null;
if (fs.exists(log)) {
os = fs.append(log);
} else {
os = fs.create(log);
}
os.writeBytes(file);
os.write('\n');
os.close();
}
public void moveTaskOutputToFinal() throws IOException {
String tempLocation = getBaseTaskAttemptTempLocation();
Path path = new Path(tempLocation);
List<String> relativePaths = Lists.newArrayList(DirectoryWalker
.with(config)
.threaded()
.omitHidden()
.add(path)
.relativePathStrings());
Path finalPath = getFinalPath();
for (String relative : relativePaths) {
LOG.info(String.format("moving (%s) from (%s) to (%s)", relative, path.toUri().toString(), finalPath
.toUri()
.toString()));
Utils.copy(new Path(relative), path, finalPath, ctx);
ctx.progress();
}
}
private Set<String> readCommitLogs(List<Path> logs) throws IOException {
Set<String> files = Sets.newHashSet();
FileSystem fs = null;
for (Path log : logs) {
// all logs are on the same filesystem.
if (fs == null) {
fs = log.getFileSystem(config);
}
BufferedReader br = new BufferedReader(new InputStreamReader(fs.open(log)));
String file;
while ((file = br.readLine()) != null) {
files.add(file);
}
if (ctx != null && files.size() % 1000 == 0) {
ctx.progress();
}
br.close();
}
return files;
}
public void setFinalPath(String path) {
config.set(CFG_OUTPUT_DIR, path);
}
}
| 8,409 |
0 | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/org | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/org/coursera/SSTableExport.java | package org.coursera;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.netflix.Aegisthus;
import com.netflix.aegisthus.input.AegisthusInputFormat;
import com.netflix.aegisthus.tools.DirectoryWalker;
import com.netflix.aegisthus.util.CFMetadataUtility;
import org.apache.avro.Schema;
import org.apache.avro.mapreduce.AvroJob;
import org.apache.avro.mapreduce.AvroKeyOutputFormat;
import org.apache.cassandra.config.CFMetaData;
import org.apache.cassandra.io.sstable.Descriptor;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.GnuParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.io.IOUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;
import org.coursera.mapreducer.CQLMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.List;
import java.util.Set;
public class SSTableExport extends Configured implements Tool {
private static final Logger LOG = LoggerFactory.getLogger(SSTableExport.class);
private Descriptor.Version version;
public static void main(String[] args) throws Exception {
int res = ToolRunner.run(new Configuration(), new SSTableExport(), args);
boolean exit = Boolean.valueOf(System.getProperty(Aegisthus.Feature.CONF_SYSTEM_EXIT, "true"));
if (exit) {
System.exit(res);
} else if (res != 0) {
throw new RuntimeException("SSTableExport finished with a non-zero exit code: " + res);
}
}
private void checkVersionFromFilename(String filename) {
Descriptor descriptor = Descriptor.fromFilename(filename);
if (this.version == null) {
this.version = descriptor.version;
} else if (!this.version.equals(descriptor.version)) {
throw new IllegalStateException("All files must have the same sstable version. File '" + filename
+ "' has version '" + descriptor.version + "' and we have already seen a file with version '"
+ version + "'");
}
}
private void setConfigurationFromCql(Configuration conf) {
CFMetaData cfMetaData = CFMetadataUtility.initializeCfMetaData(conf);
String keyType = cfMetaData.getKeyValidator().toString();
String columnType = cfMetaData.comparator.toString();
LOG.info("From CQL3, setting keyType({}) and columnType({}).", keyType, columnType);
conf.set(Aegisthus.Feature.CONF_KEYTYPE, keyType);
conf.set(Aegisthus.Feature.CONF_COLUMNTYPE, columnType);
}
List<Path> getDataFiles(Configuration conf, String dir) throws IOException {
Set<String> globs = Sets.newHashSet();
List<Path> output = Lists.newArrayList();
Path dirPath = new Path(dir);
FileSystem fs = dirPath.getFileSystem(conf);
List<FileStatus> input = Lists.newArrayList(fs.listStatus(dirPath));
for (String path : DirectoryWalker.with(conf).threaded().addAllStatuses(input).pathsString()) {
if (path.endsWith("-Data.db")) {
checkVersionFromFilename(path);
globs.add(path.replaceAll("[^/]+-Data.db", "*-Data.db"));
}
}
for (String path : globs) {
output.add(new Path(path));
}
return output;
}
@SuppressWarnings("static-access")
CommandLine getOptions(String[] args) {
Options opts = new Options();
opts.addOption(OptionBuilder.withArgName(Feature.CMD_ARG_INPUT_FILE)
.withDescription("Each input location")
.hasArgs()
.create(Feature.CMD_ARG_INPUT_FILE));
opts.addOption(OptionBuilder.withArgName(Feature.CMD_ARG_INPUT_DIR)
.withDescription("a directory from which we will recursively pull sstables")
.hasArgs()
.create(Feature.CMD_ARG_INPUT_DIR));
opts.addOption(OptionBuilder.withArgName(Feature.CMD_ARG_AVRO_SCHEMA_FILE)
.withDescription("location of avro schema")
.isRequired()
.hasArgs()
.create(Feature.CMD_ARG_AVRO_SCHEMA_FILE));
opts.addOption(OptionBuilder.withArgName(Feature.CMD_ARG_OUTPUT_DIR)
.isRequired()
.withDescription("output location")
.hasArg()
.create(Feature.CMD_ARG_OUTPUT_DIR));
CommandLineParser parser = new GnuParser();
try {
CommandLine cl = parser.parse(opts, args, true);
if (!(cl.hasOption(Feature.CMD_ARG_INPUT_FILE) || cl.hasOption(Feature.CMD_ARG_INPUT_DIR))) {
System.out.println("Must have either an input or inputDir option");
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp(String.format("hadoop jar aegisthus.jar %s", SSTableExport.class.getName()), opts);
return null;
}
return cl;
} catch (ParseException e) {
System.out.println("Unexpected exception:" + e.getMessage());
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp(String.format("hadoop jar aegisthus.jar %s", SSTableExport.class.getName()), opts);
return null;
}
}
private String getAvroSchema(String schemaLocation, Configuration conf) throws IOException {
Path schemaPath = new Path(schemaLocation);
return IOUtils.toString(schemaPath.getFileSystem(conf).open(schemaPath));
}
@Override
public int run(String[] args) throws Exception {
Job job = Job.getInstance(getConf());
job.setJarByClass(SSTableExport.class);
CommandLine cl = getOptions(args);
if (cl == null) {
return 1;
}
// Check all of the paths and load the sstable version from the input filenames
List<Path> paths = Lists.newArrayList();
if (cl.hasOption(Feature.CMD_ARG_INPUT_FILE)) {
for (String input : cl.getOptionValues(Feature.CMD_ARG_INPUT_FILE)) {
checkVersionFromFilename(input);
paths.add(new Path(input));
}
}
if (cl.hasOption(Feature.CMD_ARG_INPUT_DIR)) {
paths.addAll(getDataFiles(job.getConfiguration(), cl.getOptionValue(Feature.CMD_ARG_INPUT_DIR)));
}
String avroSchemaString = getAvroSchema(cl.getOptionValue(Feature.CMD_ARG_AVRO_SCHEMA_FILE), job.getConfiguration());
Schema avroSchema = new Schema.Parser().parse(avroSchemaString);
// At this point we have the version of sstable that we can use for this run
job.getConfiguration().set(Aegisthus.Feature.CONF_SSTABLE_VERSION, version.toString());
if (job.getConfiguration().get(Aegisthus.Feature.CONF_CQL_SCHEMA) != null) {
setConfigurationFromCql(job.getConfiguration());
}
job.setInputFormatClass(AegisthusInputFormat.class);
job.setMapperClass(CQLMapper.class);
job.setOutputFormatClass(AvroKeyOutputFormat.class);
AvroJob.setOutputKeySchema(job, avroSchema);
// Map-only job
job.setNumReduceTasks(0);
TextInputFormat.setInputPaths(job, paths.toArray(new Path[paths.size()]));
FileOutputFormat.setOutputPath(job, new Path(cl.getOptionValue(Feature.CMD_ARG_OUTPUT_DIR)));
job.submit();
System.out.println(job.getJobID());
System.out.println(job.getTrackingURL());
boolean success = job.waitForCompletion(true);
return success ? 0 : 1;
}
public static final class Feature {
public static final String CMD_ARG_INPUT_DIR = "inputDir";
public static final String CMD_ARG_INPUT_FILE = "input";
public static final String CMD_ARG_OUTPUT_DIR = "output";
public static final String CMD_ARG_AVRO_SCHEMA_FILE = "avroSchemaFile";
}
}
| 8,410 |
0 | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/org/coursera | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/org/coursera/mapreducer/CQLMapper.java | package org.coursera.mapreducer;
import com.netflix.aegisthus.io.writable.AegisthusKey;
import com.netflix.aegisthus.io.writable.AtomWritable;
import com.netflix.aegisthus.util.CFMetadataUtility;
import org.apache.avro.Schema;
import org.apache.avro.generic.GenericData;
import org.apache.avro.generic.GenericRecord;
import org.apache.avro.mapred.AvroKey;
import org.apache.avro.mapreduce.AvroJob;
import org.apache.cassandra.config.CFMetaData;
import org.apache.cassandra.cql3.CFDefinition;
import org.apache.cassandra.cql3.statements.ColumnGroupMap;
import org.apache.cassandra.db.Column;
import org.apache.cassandra.db.OnDiskAtom;
import org.apache.cassandra.db.marshal.*;
import org.apache.cassandra.utils.ByteBufferUtil;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.mapreduce.Mapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.sql.Timestamp;
import java.util.Date;
import java.util.UUID;
public class CQLMapper extends Mapper<AegisthusKey, AtomWritable, AvroKey<GenericRecord>, NullWritable> {
private static final Logger LOG = LoggerFactory.getLogger(CQLMapper.class);
ColumnGroupMap.Builder cgmBuilder;
CFMetaData cfMetaData;
CFDefinition cfDef;
ByteBuffer currentKey;
Schema avroSchema;
@Override protected void setup(
Context context)
throws IOException, InterruptedException {
avroSchema = AvroJob.getOutputKeySchema(context.getConfiguration());
cfMetaData = CFMetadataUtility.initializeCfMetaData(context.getConfiguration());
cfDef = cfMetaData.getCfDef();
initBuilder();
/* This exporter assumes tables are composite, which should be true of all current schemas */
if (!cfDef.isComposite) throw new RuntimeException("Only can export composite CQL table schemas.");
}
@Override protected void map(AegisthusKey key, AtomWritable value,
Context context)
throws IOException, InterruptedException {
if (currentKey == null) {
currentKey = key.getKey();
} else if (!currentKey.equals(key.getKey())) {
flushCgm(context);
currentKey = key.getKey();
}
OnDiskAtom atom = value.getAtom();
if (atom == null) {
LOG.warn("Got null atom for key {}.", cfMetaData.getKeyValidator().compose(key.getKey()));
return;
}
if (atom instanceof Column) {
cgmBuilder.add((Column) atom);
} else {
LOG.error("Non-colum atom. {} {}", atom.getClass(), atom);
throw new IllegalArgumentException("Got a non-column Atom.");
}
}
@Override protected void cleanup(
Context context)
throws IOException, InterruptedException {
super.cleanup(context);
if (currentKey != null) {
flushCgm(context);
}
}
private void initBuilder() {
// TODO: we might need to make "current" time configurable to avoid wrongly expiring data when trying to backfill.
cgmBuilder = new ColumnGroupMap.Builder((CompositeType) cfMetaData.comparator,
cfDef.hasCollections, System.currentTimeMillis());
}
private void flushCgm(Context context) throws IOException, InterruptedException {
if (cgmBuilder.isEmpty())
return;
ByteBuffer[] keyComponents =
cfDef.hasCompositeKey
? ((CompositeType) cfMetaData.getKeyValidator()).split(currentKey)
: new ByteBuffer[] { currentKey };
ColumnGroupMap staticGroup = ColumnGroupMap.EMPTY;
if (!cgmBuilder.isEmpty() && cgmBuilder.firstGroup().isStatic) {
staticGroup = cgmBuilder.firstGroup();
cgmBuilder.discardFirst();
// Special case: if there are no rows, but only the static values, just flush the static values.
if (cgmBuilder.isEmpty()) {
handleGroup(context, ColumnGroupMap.EMPTY, keyComponents, staticGroup);
}
}
for (ColumnGroupMap group : cgmBuilder.groups()) {
handleGroup(context, group, keyComponents, staticGroup);
}
initBuilder();
currentKey = null;
}
private void handleGroup(Context context, ColumnGroupMap group, ByteBuffer[] keyComponents, ColumnGroupMap staticGroup)
throws IOException, InterruptedException {
GenericRecord record = new GenericData.Record(avroSchema);
// write out partition keys
for (CFDefinition.Name name : cfDef.partitionKeys()) {
addCqlValueToRecord(record, name, keyComponents[name.position]);
}
// write out clustering columns
for (CFDefinition.Name name : cfDef.clusteringColumns()) {
addCqlValueToRecord(record, name, group.getKeyComponent(name.position));
}
// regular columns
for (CFDefinition.Name name : cfDef.regularColumns()) {
addValue(record, name, group);
}
// static columns
for (CFDefinition.Name name : cfDef.staticColumns()) {
addValue(record, name, staticGroup);
}
context.write(new AvroKey(record), NullWritable.get());
}
/* adapted from org.apache.cassandra.cql3.statements.SelectStatement.addValue */
private void addValue(GenericRecord record, CFDefinition.Name name, ColumnGroupMap group) {
if (name.type.isCollection()) {
// TODO(danchia): support collections
throw new RuntimeException("Collections not supported yet.");
} else {
Column c = group.getSimple(name.name.key);
addCqlValueToRecord(record, name, (c == null) ? null : c.value());
}
}
private void addCqlValueToRecord(GenericRecord record, CFDefinition.Name name, ByteBuffer value) {
if (value == null) {
record.put(name.name.toString(), null);
return;
}
AbstractType<?> type = name.type;
Object valueDeserialized = type.compose(value);
AbstractType<?> baseType = (type instanceof ReversedType<?>)
? ((ReversedType<?>) type).baseType
: type;
/* special case some unsupported CQL3 types to Hive types. */
if (baseType instanceof UUIDType || baseType instanceof TimeUUIDType) {
valueDeserialized = ((UUID) valueDeserialized).toString();
} else if (baseType instanceof BytesType) {
ByteBuffer buffer = (ByteBuffer) valueDeserialized;
byte[] data = new byte[buffer.remaining()];
buffer.get(data);
valueDeserialized = data;
} else if (baseType instanceof TimestampType) {
Date date = (Date) valueDeserialized;
valueDeserialized = date.getTime();
}
//LOG.info("Setting {} type {} to class {}", name.name.toString(), type, valueDeserialized.getClass());
record.put(name.name.toString(), valueDeserialized);
}
}
| 8,411 |
0 | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/Aegisthus.java | /**
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.netflix.aegisthus.input.AegisthusCombinedInputFormat;
import com.netflix.aegisthus.input.AegisthusInputFormat;
import com.netflix.aegisthus.io.writable.AegisthusKey;
import com.netflix.aegisthus.io.writable.AegisthusKeyGroupingComparator;
import com.netflix.aegisthus.io.writable.AegisthusKeyMapper;
import com.netflix.aegisthus.io.writable.AegisthusKeyPartitioner;
import com.netflix.aegisthus.io.writable.AegisthusKeySortingComparator;
import com.netflix.aegisthus.io.writable.AtomWritable;
import com.netflix.aegisthus.io.writable.RowWritable;
import com.netflix.aegisthus.mapreduce.CassSSTableReducer;
import com.netflix.aegisthus.output.CustomFileNameFileOutputFormat;
import com.netflix.aegisthus.output.JsonOutputFormat;
import com.netflix.aegisthus.output.SSTableOutputFormat;
import com.netflix.aegisthus.tools.DirectoryWalker;
import com.netflix.aegisthus.util.CFMetadataUtility;
import com.netflix.aegisthus.util.JobKiller;
import org.apache.cassandra.config.CFMetaData;
import org.apache.cassandra.io.sstable.Descriptor;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.GnuParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapreduce.Counter;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.List;
import java.util.Set;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
public class Aegisthus extends Configured implements Tool {
private static final Logger LOG = LoggerFactory.getLogger(Aegisthus.class);
private static void logAegisthusVersion() {
String classPath = Aegisthus.class.getResource("Aegisthus.class").toString();
String manifestPath = classPath.replace("com/netflix/Aegisthus.class", "META-INF/MANIFEST.MF");
try (InputStream inputStream = new URL(manifestPath).openStream()) {
Manifest manifest = new Manifest(inputStream);
Attributes attr = manifest.getMainAttributes();
System.out.println("Running Aegisthus version " +
attr.getValue("Implementation-Version") +
" built from change " +
attr.getValue("Change") +
" on host " +
attr.getValue("Build-Host") +
" on " +
attr.getValue("Build-Date") +
" with Java " +
attr.getValue("Build-Java-Version")
);
} catch (IOException ignored) {
System.out.println("Unable to locate Aegisthus manifest file");
}
}
public static void main(String[] args) throws Exception {
logAegisthusVersion();
int res = ToolRunner.run(new Configuration(), new Aegisthus(), args);
boolean exit = Boolean.valueOf(System.getProperty(Feature.CONF_SYSTEM_EXIT, "true"));
if (exit) {
System.exit(res);
} else if (res != 0) {
throw new RuntimeException("aegisthus finished with a non-zero exit code: " + res);
}
}
private void setConfigurationFromCql(Configuration conf) {
CFMetaData cfMetaData = CFMetadataUtility.initializeCfMetaData(conf);
String keyType = cfMetaData.getKeyValidator().toString();
String columnType = cfMetaData.comparator.toString();
LOG.info("From CQL3, setting keyType({}) and columnType({}).", keyType, columnType);
conf.set(Feature.CONF_KEYTYPE, keyType);
conf.set(Feature.CONF_COLUMNTYPE, columnType);
}
List<Path> getDataFiles(Configuration conf, String dir) throws IOException {
Set<Path> globs = Sets.newHashSet();
Iterable<Path> paths = DirectoryWalker.with(conf)
.add(dir)
.recursive(true)
.omitHidden(true)
.manifest(false)
.threaded()
.paths();
for (Path path : paths) {
String pathName = path.getName();
if (pathName.endsWith("-Data.db")) {
Path outputPath = new Path(path.getParent(), pathName.replaceAll("[^/]+-Data.db", "*-Data.db"));
globs.add(outputPath);
}
}
return ImmutableList.copyOf(globs);
}
@SuppressWarnings("static-access")
CommandLine getOptions(String[] args) {
Options opts = new Options();
opts.addOption(OptionBuilder.withArgName(Feature.CMD_ARG_INPUT_FILE)
.withDescription("Each input location")
.hasArgs()
.create(Feature.CMD_ARG_INPUT_FILE));
opts.addOption(OptionBuilder.withArgName(Feature.CMD_ARG_OUTPUT_DIR)
.isRequired()
.withDescription("output location")
.hasArg()
.create(Feature.CMD_ARG_OUTPUT_DIR));
opts.addOption(OptionBuilder.withArgName(Feature.CMD_ARG_INPUT_DIR)
.withDescription("a directory from which we will recursively pull sstables")
.hasArgs()
.create(Feature.CMD_ARG_INPUT_DIR));
opts.addOption(OptionBuilder.withArgName(Feature.CMD_ARG_PRODUCE_SSTABLE)
.withDescription("produces sstable output (default is to produce json)")
.create(Feature.CMD_ARG_PRODUCE_SSTABLE));
opts.addOption(OptionBuilder.withArgName(Feature.CMD_ARG_COMBINE_SPLITS)
.withDescription("combine together small input splits (default is to not combine input splits)")
.create(Feature.CMD_ARG_COMBINE_SPLITS));
opts.addOption(OptionBuilder.withArgName(Feature.CMD_ARG_SSTABLE_OUTPUT_VERSION)
.withDescription("version of sstable to produce (default is to produce " +
Descriptor.Version.current_version
+ ")")
.hasArg()
.create(Feature.CMD_ARG_SSTABLE_OUTPUT_VERSION));
CommandLineParser parser = new GnuParser();
try {
CommandLine cl = parser.parse(opts, args, true);
if (!(cl.hasOption(Feature.CMD_ARG_INPUT_FILE) || cl.hasOption(Feature.CMD_ARG_INPUT_DIR))) {
System.out.println("Must have either an input or inputDir option");
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp(String.format("hadoop jar aegisthus.jar %s", Aegisthus.class.getName()), opts);
return null;
}
return cl;
} catch (ParseException e) {
System.out.println("Unexpected exception:" + e.getMessage());
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp(String.format("hadoop jar aegisthus.jar %s", Aegisthus.class.getName()), opts);
return null;
}
}
@Override
public int run(String[] args) throws Exception {
Job job = Job.getInstance(getConf());
Configuration configuration = job.getConfiguration();
job.setJarByClass(Aegisthus.class);
CommandLine cl = getOptions(args);
if (cl == null) {
return 1;
}
// Check all of the paths and load the sstable version from the input filenames
List<Path> paths = Lists.newArrayList();
if (cl.hasOption(Feature.CMD_ARG_INPUT_FILE)) {
for (String input : cl.getOptionValues(Feature.CMD_ARG_INPUT_FILE)) {
paths.add(new Path(input));
}
}
if (cl.hasOption(Feature.CMD_ARG_INPUT_DIR)) {
paths.addAll(getDataFiles(configuration, cl.getOptionValue(Feature.CMD_ARG_INPUT_DIR)));
}
LOG.info("Processing paths: {}", paths);
// At this point we have the version of sstable that we can use for this run
Descriptor.Version version = Descriptor.Version.CURRENT;
if (cl.hasOption(Feature.CMD_ARG_SSTABLE_OUTPUT_VERSION)) {
version = new Descriptor.Version(cl.getOptionValue(Feature.CMD_ARG_SSTABLE_OUTPUT_VERSION));
}
configuration.set(Feature.CONF_SSTABLE_VERSION, version.toString());
if (configuration.get(Feature.CONF_CQL_SCHEMA) != null) {
setConfigurationFromCql(configuration);
}
if(cl.hasOption(Feature.CMD_ARG_COMBINE_SPLITS)) {
job.setInputFormatClass(AegisthusCombinedInputFormat.class);
} else {
job.setInputFormatClass(AegisthusInputFormat.class);
}
job.setMapOutputKeyClass(AegisthusKey.class);
job.setMapOutputValueClass(AtomWritable.class);
job.setOutputKeyClass(AegisthusKey.class);
job.setOutputValueClass(RowWritable.class);
job.setMapperClass(AegisthusKeyMapper.class);
job.setReducerClass(CassSSTableReducer.class);
job.setGroupingComparatorClass(AegisthusKeyGroupingComparator.class);
job.setPartitionerClass(AegisthusKeyPartitioner.class);
job.setSortComparatorClass(AegisthusKeySortingComparator.class);
TextInputFormat.setInputPaths(job, paths.toArray(new Path[paths.size()]));
if (cl.hasOption(Feature.CMD_ARG_PRODUCE_SSTABLE)) {
job.setOutputFormatClass(SSTableOutputFormat.class);
} else {
job.setOutputFormatClass(JsonOutputFormat.class);
}
CustomFileNameFileOutputFormat.setOutputPath(job, new Path(cl.getOptionValue(Feature.CMD_ARG_OUTPUT_DIR)));
job.submit();
if (configuration.getBoolean(Feature.CONF_SHUTDOWN_HOOK, true)) {
Runtime.getRuntime().addShutdownHook(new JobKiller(job));
}
System.out.println(job.getJobID());
System.out.println(job.getTrackingURL());
boolean success = job.waitForCompletion(true);
if (success) {
Counter errorCounter = job.getCounters().findCounter("aegisthus", "error_skipped_input");
long errorCount = errorCounter != null ? errorCounter.getValue() : 0L;
int maxAllowed = configuration.getInt(Feature.CONF_MAX_CORRUPT_FILES_TO_SKIP, 0);
if (errorCounter != null && errorCounter.getValue() > maxAllowed) {
LOG.error("Found {} corrupt files which is greater than the max allowed {}", errorCount, maxAllowed);
success = false;
} else if (errorCount > 0) {
LOG.warn("Found {} corrupt files but not failing the job because the max allowed is {}",
errorCount, maxAllowed);
}
}
return success ? 0 : 1;
}
public static final class Feature {
public static final String CMD_ARG_COMBINE_SPLITS = "combineSplits";
public static final String CMD_ARG_INPUT_DIR = "inputDir";
public static final String CMD_ARG_INPUT_FILE = "input";
public static final String CMD_ARG_OUTPUT_DIR = "output";
public static final String CMD_ARG_PRODUCE_SSTABLE = "produceSSTable";
public static final String CMD_ARG_SSTABLE_OUTPUT_VERSION = "sstable_output_version";
/**
* If set this is the blocksize aegisthus will use when splitting input files otherwise the hadoop vaule will
* be used.
*/
public static final String CONF_BLOCKSIZE = "aegisthus.blocksize";
/**
* The column type, used for sorting columns in all output formats and also in the JSON output format. The
* default is BytesType.
*/
public static final String CONF_COLUMNTYPE = "aegisthus.columntype";
/**
* The converter to use for the column value, used in the JSON output format. The default is BytesType.
*/
public static final String CONF_COLUMN_VALUE_TYPE = "aegisthus.column_value_type";
/**
* Name of the keyspace and dataset to use for the output sstable file name. The default is "keyspace-dataset".
*/
public static final String CONF_DATASET = "aegisthus.dataset";
/**
* The converter to use for the key, used in the JSON output format. The default is BytesType.
*/
public static final String CONF_KEYTYPE = "aegisthus.keytype";
/**
* Earlier versions of Aegisthus did extra formatting on just the column name. This defaults to false.
*/
public static final String CONF_LEGACY_COLUMN_NAME_FORMATTING = "aegisthus.legacy_column_name_formatting";
/**
* If set rows with columns larger than this size will be dropped during the reduce stage.
* For legacy reasons this is based on the size of the columns on disk in SSTable format not the string size of
* the columns.
*/
public static final String CONF_MAXCOLSIZE = "aegisthus.maxcolsize";
/**
* The maximum number of files that can be combined in a single input split. Defaults to 200.
*/
public static final String CONF_MAX_COMBINED_SPLITS = "aegisthus.max_combined_splits";
/**
* The maximum number of corrupt files that Aegisthus can automatically skip. Defaults to 0.
*/
public static final String CONF_MAX_CORRUPT_FILES_TO_SKIP = "aegisthus.max_corrupt_files_to_skip";
/**
* Whether to add a shutdown hook to kill the hadoop job. Defaults to true.
*/
public static final String CONF_SHUTDOWN_HOOK = "aegisthus.shutdown_hook";
/**
* Sort the columns by name rather than by the order in Cassandra. This defaults to false.
*/
public static final String CONF_SORT_COLUMNS_BY_NAME = "aegisthus.sort_columns_by_name";
/**
* The version of SSTable to input and output.
*/
public static final String CONF_SSTABLE_VERSION = "aegisthus.version_of_sstable";
/**
* Configures if the System.exit should be called to end the processing in main. Defaults to true.
*/
public static final String CONF_SYSTEM_EXIT = "aegisthus.exit";
/**
* The CQL "Create Table" statement that defines the schema of the input sstables.
*/
public static final String CONF_CQL_SCHEMA = "aegisthus.cql_schema";
/**
* When this is enabled, Aegisthus keeps track of which source file all data came from. When used with
* the json output format the filename will be output with the row. Note: that this is just for debugging,
* when enabled rows from different source files will not be combined. Defaults to false.
*/
public static final String CONF_TRACE_DATA_FROM_SOURCE = "aegisthus.trace_source";
}
}
| 8,412 |
0 | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/util/ObservableToIterator.java | package com.netflix.aegisthus.util;
import rx.Notification;
import rx.Observable;
import rx.Subscriber;
import rx.exceptions.Exceptions;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
/**
* Most of this code is borrowed from rx.internal.operators.BlockingOperatorToIterator, which sadly does not offer a way
* to apply backpressure.
*/
public class ObservableToIterator {
public static <T> Iterator<T> toIterator(Observable<? extends T> source) {
return toIterator(source, 25);
}
/**
* Returns an iterator that iterates all values of the observable. Has bounded buffer, blocks source when buffer
* gets full.
*/
public static <T> Iterator<T> toIterator(Observable<? extends T> source, int bufferSize) {
final BlockingQueue<Notification<? extends T>> notifications = new LinkedBlockingQueue<Notification<? extends T>>(bufferSize);
// using subscribe instead of unsafeSubscribe since this is a BlockingObservable "final subscribe"
source.materialize().subscribe(new Subscriber<Notification<? extends T>>() {
@Override
public void onCompleted() {
// ignore
}
@Override
public void onError(Throwable e) {
// ignore
}
@Override
public void onNext(Notification<? extends T> args) {
try {
notifications.put(args);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
});
return new Iterator<T>() {
private Notification<? extends T> buf;
@Override
public boolean hasNext() {
if (buf == null) {
buf = take();
}
if (buf.isOnError()) {
throw Exceptions.propagate(buf.getThrowable());
}
return !buf.isOnCompleted();
}
@Override
public T next() {
if (hasNext()) {
T result = buf.getValue();
buf = null;
return result;
}
throw new NoSuchElementException();
}
private Notification<? extends T> take() {
try {
return notifications.take();
} catch (InterruptedException e) {
throw Exceptions.propagate(e);
}
}
@Override
public void remove() {
throw new UnsupportedOperationException("Read-only iterator");
}
};
}
}
| 8,413 |
0 | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/util/JobKiller.java | package com.netflix.aegisthus.util;
import com.google.common.base.Throwables;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.JobStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
public class JobKiller extends Thread {
private static final Logger log = LoggerFactory.getLogger(JobKiller.class);
private final Job job;
public JobKiller(Job job) {
this.job = job;
}
@Override
public void run() {
try {
if (job.getJobState() == JobStatus.State.RUNNING) {
job.killJob();
} else {
log.info("Job {} was already killed.", job.getJobID());
}
} catch (IOException | InterruptedException e) {
log.error("Error killing job {}", job.getJobID(), e);
Throwables.propagate(e);
}
}
}
| 8,414 |
0 | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/util/CFMetadataUtility.java | package com.netflix.aegisthus.util;
import com.google.common.base.Preconditions;
import com.netflix.Aegisthus;
import org.apache.cassandra.config.CFMetaData;
import org.apache.cassandra.cql3.QueryProcessor;
import org.apache.cassandra.cql3.statements.CreateTableStatement;
import org.apache.cassandra.exceptions.RequestValidationException;
import org.apache.hadoop.conf.Configuration;
public class CFMetadataUtility {
public static CFMetaData initializeCfMetaData(Configuration configuration) {
final String cql = configuration.get(Aegisthus.Feature.CONF_CQL_SCHEMA);
Preconditions.checkNotNull(cql, "Cannot proceed without CQL definition.");
final CreateTableStatement statement = getCreateTableStatement(cql);
try {
final CFMetaData cfMetaData = statement.getCFMetaData();
cfMetaData.rebuild();
return cfMetaData;
} catch (RequestValidationException e) {
// Cannot proceed if an error occurs
throw new RuntimeException("Error initializing CFMetadata from CQL.", e);
}
}
private static CreateTableStatement getCreateTableStatement(String cql) {
CreateTableStatement statement;
try {
statement = (CreateTableStatement) QueryProcessor.parseStatement(cql).prepare().statement;
} catch (RequestValidationException e) {
// Cannot proceed if an error occurs
throw new RuntimeException("Error configuring SSTable reader. Cannot proceed", e);
}
return statement;
}
}
| 8,415 |
0 | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/input/AegisthusCombinedInputFormat.java | /**
* Copyright 2014 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.aegisthus.input;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.netflix.Aegisthus;
import com.netflix.aegisthus.input.readers.CombineSSTableReader;
import com.netflix.aegisthus.input.splits.AegCombinedSplit;
import com.netflix.aegisthus.input.splits.AegSplit;
import com.netflix.aegisthus.io.writable.AegisthusKey;
import com.netflix.aegisthus.io.writable.AtomWritable;
import org.apache.hadoop.mapreduce.InputSplit;
import org.apache.hadoop.mapreduce.JobContext;
import org.apache.hadoop.mapreduce.RecordReader;
import org.apache.hadoop.mapreduce.TaskAttemptContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* This class takes the splits created by the AegisthusInputFormat and combines
* small SSTables into single splits.
*/
public class AegisthusCombinedInputFormat extends AegisthusInputFormat {
private static final Logger log = LoggerFactory.getLogger(AegisthusCombinedInputFormat.class);
@Override
public RecordReader<AegisthusKey, AtomWritable> createRecordReader(InputSplit inputSplit,
TaskAttemptContext context) throws IOException, InterruptedException {
if (AegCombinedSplit.class.isAssignableFrom(inputSplit.getClass())) {
return new CombineSSTableReader();
} else {
return super.createRecordReader(inputSplit, context);
}
}
@Override
public List<InputSplit> getSplits(JobContext job) throws IOException {
String tmp = job.getConfiguration().getTrimmed(Aegisthus.Feature.CONF_BLOCKSIZE, "104857600");
long maxSplitSize = Long.valueOf(tmp);
tmp = job.getConfiguration().getTrimmed(Aegisthus.Feature.CONF_MAX_COMBINED_SPLITS, "200");
int maxSplitCount = Integer.valueOf(tmp);
List<InputSplit> splits = super.getSplits(job);
List<InputSplit> combinedSplits = Lists.newArrayList();
Map<String, AegCombinedSplit> map = Maps.newHashMap();
top:
for (InputSplit split : splits) {
AegSplit aegSplit = (AegSplit) split;
if (aegSplit.getLength() >= maxSplitSize) {
combinedSplits.add(aegSplit);
continue;
}
try {
String lastLocation = null;
for (String location : aegSplit.getLocations()) {
lastLocation = location;
if (map.containsKey(location)) {
AegCombinedSplit temp = map.get(location);
temp.addSplit(aegSplit);
if (temp.getLength() >= maxSplitSize || temp.getSplits().size() >= maxSplitCount) {
combinedSplits.add(temp);
map.remove(location);
}
continue top;
}
}
AegCombinedSplit temp = new AegCombinedSplit();
temp.addSplit(aegSplit);
map.put(lastLocation, temp);
} catch (InterruptedException e) {
throw new IOException(e);
}
}
for (AegCombinedSplit split : map.values()) {
combinedSplits.add(split);
}
log.info("Original split count: {}", splits.size());
log.info("Combined split count: {}", combinedSplits.size());
return combinedSplits;
}
}
| 8,416 |
0 | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/input/AegisthusInputFormat.java | /**
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.aegisthus.input;
import com.google.common.base.Optional;
import com.google.common.base.Strings;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
import com.netflix.Aegisthus;
import com.netflix.aegisthus.input.readers.SSTableRecordReader;
import com.netflix.aegisthus.input.splits.AegCompressedSplit;
import com.netflix.aegisthus.input.splits.AegSplit;
import com.netflix.aegisthus.io.sstable.IndexDatabaseScanner;
import com.netflix.aegisthus.io.writable.AegisthusKey;
import com.netflix.aegisthus.io.writable.AtomWritable;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.BlockLocation;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapreduce.InputSplit;
import org.apache.hadoop.mapreduce.JobContext;
import org.apache.hadoop.mapreduce.RecordReader;
import org.apache.hadoop.mapreduce.TaskAttemptContext;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* The AegisthusInputFormat class handles creating splits and record readers.
*/
public class AegisthusInputFormat extends FileInputFormat<AegisthusKey, AtomWritable> {
private static final Logger LOG = LoggerFactory.getLogger(AegisthusInputFormat.class);
private static final Pattern PATH_DATETIME_MATCHER = Pattern.compile(".+/-?\\d+/(\\d{12})/.+");
@Override
public RecordReader<AegisthusKey, AtomWritable> createRecordReader(InputSplit inputSplit,
TaskAttemptContext context) throws IOException, InterruptedException {
return new SSTableRecordReader();
}
/**
* Look for a CompressionInfo.db file that matches the given Data.db file.
*
* @param fs the path file system
* @param dataDbPath the reference to a Data.db file
* @return an optional CompressionInfo.db file that matches the Data.db file.
* @throws IOException on file system errors.
*/
Optional<Path> getCompressionPath(FileSystem fs, Path dataDbPath) throws IOException {
final String fullPath = dataDbPath.toString().replaceAll("-Data.db", "-CompressionInfo.db");
Path testPath = new Path(fullPath);
if (fs.exists(testPath)) {
return Optional.of(testPath);
}
// If a CompressionInfo file wasn't found in the same directory, check to see if the path has a date time in it
Matcher matcher = PATH_DATETIME_MATCHER.matcher(fullPath);
if (!matcher.matches()) {
return Optional.absent();
}
// the path looks like it has a date time, we will check the adjacent minutes for the CompressionInfo file also.
String dateTime = matcher.group(1);
long dateTimeNumeric = Long.valueOf(dateTime);
// check the next minute
testPath = new Path(fullPath.replace("/" + dateTime + "/", "/" + Long.toString(dateTimeNumeric + 1) + "/"));
if (fs.exists(testPath)) {
return Optional.of(testPath);
}
// check the previous minute
testPath = new Path(fullPath.replace("/" + dateTime + "/", "/" + Long.toString(dateTimeNumeric - 1) + "/"));
if (fs.exists(testPath)) {
return Optional.of(testPath);
}
return Optional.absent();
}
/**
* The main thing that the addSSTableSplit handles is to split SSTables
* using their index if available. The general algorithm is that if the file
* is large than the blocksize plus some fuzzy factor to
*/
List<InputSplit> getSSTableSplitsForFile(JobContext job, FileStatus file) throws IOException {
long length = file.getLen();
if (length == 0) {
LOG.info("skipping zero length file: {}", file.getPath());
return Collections.emptyList();
}
Path path = file.getPath();
Configuration conf = job.getConfiguration();
FileSystem fs = path.getFileSystem(conf);
BlockLocation[] blkLocations = fs.getFileBlockLocations(file, 0, length);
Optional<Path> compressionPath = getCompressionPath(fs, path);
if (compressionPath.isPresent()) {
return ImmutableList.of((InputSplit) AegCompressedSplit.createAegCompressedSplit(path, 0, length,
blkLocations[blkLocations.length - 1].getHosts(), compressionPath.get(), conf));
}
long blockSize = file.getBlockSize();
String aegisthusBlockSize = conf.get(Aegisthus.Feature.CONF_BLOCKSIZE);
if (!Strings.isNullOrEmpty(aegisthusBlockSize)) {
blockSize = Long.valueOf(aegisthusBlockSize);
}
long maxSplitSize = (long) (blockSize * .99);
long fuzzySplit = (long) (blockSize * 1.2);
long bytesRemaining = length;
List<InputSplit> splits = Lists.newArrayList();
IndexDatabaseScanner scanner = null;
// Only initialize if we are going to have more than a single split
if (fuzzySplit < length) {
Path indexPath = new Path(path.getParent(), path.getName().replaceAll("-Data.db", "-Index.db"));
if (!fs.exists(indexPath)) {
fuzzySplit = length;
} else {
FSDataInputStream fileIn = fs.open(indexPath);
scanner = new IndexDatabaseScanner(new BufferedInputStream(fileIn));
}
}
long splitStart = 0;
while (splitStart + fuzzySplit < length && scanner != null && scanner.hasNext()) {
long splitSize = 0;
// The scanner returns an offset from the start of the file.
while (splitSize < maxSplitSize && scanner.hasNext()) {
IndexDatabaseScanner.OffsetInfo offsetInfo = scanner.next();
splitSize = offsetInfo.getDataFileOffset() - splitStart;
}
int blkIndex = getBlockIndex(blkLocations, splitStart + (splitSize / 2));
LOG.debug("split path: {}:{}:{}", path.getName(), splitStart, splitSize);
splits.add(AegSplit.createSplit(path, splitStart, splitSize, blkLocations[blkIndex].getHosts()));
bytesRemaining -= splitSize;
splitStart += splitSize;
}
if (scanner != null) {
scanner.close();
}
if (bytesRemaining != 0) {
LOG.debug("end path: {}:{}:{}", path.getName(), length - bytesRemaining, bytesRemaining);
splits.add(AegSplit.createSplit(path, length - bytesRemaining, bytesRemaining,
blkLocations[blkLocations.length - 1].getHosts()));
}
return splits;
}
@Override
public List<InputSplit> getSplits(final JobContext job) throws IOException {
// TODO switch to Java 8 and replace this with streams
List<FileStatus> allFiles = listStatus(job);
List<FileStatus> dataFiles = Lists.newLinkedList();
final Queue<InputSplit> allSplits = new ConcurrentLinkedQueue<>();
for (FileStatus file : allFiles) {
String name = file.getPath().getName();
if (name.endsWith("-Data.db")) {
dataFiles.add(file);
}
}
LOG.info("Calculating splits for {} input files of which {} are data files", allFiles.size(), dataFiles.size());
// TODO make the number of threads configurable
ListeningExecutorService service = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(20));
for (final FileStatus file : dataFiles) {
ListenableFuture<List<InputSplit>> future = service.submit(new Callable<List<InputSplit>>() {
public List<InputSplit> call() throws IOException {
List<InputSplit> splitsForFile = getSSTableSplitsForFile(job, file);
LOG.info("Split '{}' into {} splits", file.getPath(), splitsForFile.size());
return splitsForFile;
}
});
Futures.addCallback(future, new FutureCallback<List<InputSplit>>() {
public void onFailure(Throwable thrown) {
throw Throwables.propagate(thrown);
}
public void onSuccess(List<InputSplit> splits) {
allSplits.addAll(splits);
}
});
}
try {
service.shutdown();
// TODO timeout configurable
service.awaitTermination(2, TimeUnit.HOURS);
} catch (InterruptedException e) {
throw Throwables.propagate(e);
}
ImmutableList<InputSplit> inputSplits = ImmutableList.copyOf(allSplits);
LOG.info("Split {} input data files into {} parts", dataFiles.size(), inputSplits.size());
return inputSplits;
}
}
| 8,417 |
0 | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/input | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/input/readers/CombineSSTableReader.java | /**
* Copyright 2014 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.aegisthus.input.readers;
import com.netflix.aegisthus.input.splits.AegCombinedSplit;
import com.netflix.aegisthus.io.writable.AegisthusKey;
import com.netflix.aegisthus.io.writable.AtomWritable;
import org.apache.hadoop.mapreduce.InputSplit;
import org.apache.hadoop.mapreduce.RecordReader;
import org.apache.hadoop.mapreduce.TaskAttemptContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
public class CombineSSTableReader extends RecordReader<AegisthusKey, AtomWritable> {
private static final Logger log = LoggerFactory.getLogger(CombineSSTableReader.class);
private TaskAttemptContext ctx;
private AegCombinedSplit splits;
private int currentSplitNumber;
private int splitCount;
private SSTableRecordReader reader;
@Override
public void initialize(InputSplit split, TaskAttemptContext ctx) throws IOException, InterruptedException {
this.ctx = ctx;
splits = (AegCombinedSplit) split;
currentSplitNumber = 0;
splitCount = splits.getSplits().size();
log.info("splits to process: {}", splitCount);
reader = new SSTableRecordReader();
reader.initialize(splits.getSplits().get(currentSplitNumber), this.ctx);
}
@Override
public boolean nextKeyValue() throws IOException, InterruptedException {
boolean resp = reader.nextKeyValue();
if (resp) {
return true;
}
reader.close();
currentSplitNumber++;
if (currentSplitNumber >= splits.getSplits().size()) {
return false;
}
log.info("Switching to split number {}", currentSplitNumber);
reader.initialize(splits.getSplits().get(currentSplitNumber), this.ctx);
return reader.nextKeyValue();
}
@Override
public AegisthusKey getCurrentKey() throws IOException, InterruptedException {
return reader.getCurrentKey();
}
@Override
public AtomWritable getCurrentValue() throws IOException, InterruptedException {
return reader.getCurrentValue();
}
@Override
public float getProgress() throws IOException, InterruptedException {
float currentFileProgress = currentSplitNumber + reader.getProgress();
return Math.min(1.0f, currentFileProgress / splitCount);
}
@Override
public void close() throws IOException {
if (reader != null) {
reader.close();
}
}
}
| 8,418 |
0 | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/input | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/input/readers/SSTableRecordReader.java | /**
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.aegisthus.input.readers;
import com.netflix.Aegisthus;
import com.netflix.aegisthus.input.splits.AegSplit;
import com.netflix.aegisthus.io.sstable.SSTableColumnScanner;
import com.netflix.aegisthus.io.writable.AegisthusKey;
import com.netflix.aegisthus.io.writable.AtomWritable;
import com.netflix.aegisthus.util.ObservableToIterator;
import org.apache.cassandra.io.sstable.Descriptor;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.mapreduce.InputSplit;
import org.apache.hadoop.mapreduce.RecordReader;
import org.apache.hadoop.mapreduce.TaskAttemptContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import rx.Observable;
import rx.exceptions.OnErrorThrowable;
import rx.functions.Func1;
import javax.annotation.Nonnull;
import java.io.IOError;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.nio.ByteBuffer;
import java.util.Iterator;
public class SSTableRecordReader extends RecordReader<AegisthusKey, AtomWritable> {
private static final Logger LOG = LoggerFactory.getLogger(SSTableRecordReader.class);
private boolean traceDataFromSource;
private Iterator<AtomWritable> iterator;
private String sourcePath;
private AegisthusKey key;
private SSTableColumnScanner scanner;
private AtomWritable value;
@Override
public void close() throws IOException {
if (scanner != null) {
scanner.close();
}
}
@Override
public AegisthusKey getCurrentKey() throws IOException, InterruptedException {
return key;
}
@Override
public AtomWritable getCurrentValue() throws IOException, InterruptedException {
return value;
}
@Override
public float getProgress() throws IOException, InterruptedException {
if (scanner.getStart() == scanner.getEnd()) {
return 0.0f;
} else {
long completed = scanner.getPos() - scanner.getStart();
float total = scanner.getEnd() - scanner.getStart();
return Math.min(1.0f, completed / total);
}
}
@Override
public void initialize(@Nonnull InputSplit inputSplit, @Nonnull final TaskAttemptContext ctx)
throws IOException, InterruptedException {
Configuration conf = ctx.getConfiguration();
final AegSplit split = (AegSplit) inputSplit;
long start = split.getStart();
InputStream is = split.getInput(conf);
long end = split.getDataEnd();
URI fileUri = split.getPath().toUri();
String filename = fileUri.toString();
sourcePath = fileUri.getPath();
traceDataFromSource = conf.getBoolean(Aegisthus.Feature.CONF_TRACE_DATA_FROM_SOURCE, false);
LOG.info("File: {}", sourcePath);
LOG.info("Start: {}", start);
LOG.info("End: {}", end);
try {
Descriptor.Version version = Descriptor.Version.CURRENT;
try {
version = Descriptor.fromFilename(filename).version;
} catch (Exception ignored) {
// The 2.0 fromFilename parser fails on the latest Cassandra filenames, ignore this error and uses latest
}
scanner = new SSTableColumnScanner(is, start, end, version);
LOG.info("Creating observable");
rx.Observable<AtomWritable> observable = scanner.observable();
observable = observable
.onErrorFlatMap(new Func1<OnErrorThrowable, Observable<? extends AtomWritable>>() {
@Override
public Observable<? extends AtomWritable> call(OnErrorThrowable onErrorThrowable) {
LOG.error("failure deserializing file {}", split.getPath(), onErrorThrowable);
ctx.getCounter("aegisthus", "error_skipped_input").increment(1L);
return Observable.empty();
}
});
iterator = ObservableToIterator.toIterator(observable);
LOG.info("done initializing");
} catch (IOException e) {
throw new IOError(e);
}
}
@Override
public boolean nextKeyValue() throws IOException, InterruptedException {
if (!iterator.hasNext()) {
return false;
}
value = iterator.next();
if (value.getAtom() != null) {
key = AegisthusKey.createKeyForRowColumnPair(
ByteBuffer.wrap(value.getKey()),
traceDataFromSource ? sourcePath : "",
value.getAtom().name(),
value.getAtom().maxTimestamp()
);
} else {
key = AegisthusKey.createKeyForRow(ByteBuffer.wrap(value.getKey()), traceDataFromSource ? sourcePath : "");
}
return true;
}
}
| 8,419 |
0 | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/input | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/input/splits/AegCombinedSplit.java | /**
* Copyright 2014 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.aegisthus.input.splits;
import com.google.common.base.Throwables;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.io.WritableUtils;
import org.apache.hadoop.mapreduce.InputSplit;
import javax.annotation.Nonnull;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.List;
import java.util.Set;
public class AegCombinedSplit extends InputSplit implements Writable {
private static final LoadingCache<String, Class<AegSplit>> AEG_SPLIT_LOADING_CACHE = CacheBuilder.newBuilder()
.build(new CacheLoader<String, Class<AegSplit>>() {
@Override
public Class<AegSplit> load(@Nonnull String className) throws Exception {
return (Class<AegSplit>) Class.forName(className);
}
});
List<AegSplit> splits = Lists.newArrayList();
public AegCombinedSplit() {
}
@Override
public void readFields(DataInput in) throws IOException {
try {
int cnt = in.readInt();
for (int i = 0; i < cnt; i++) {
String className = WritableUtils.readString(in);
AegSplit split = AEG_SPLIT_LOADING_CACHE.get(className).newInstance();
split.readFields(in);
splits.add(split);
}
} catch (Throwable t) {
Throwables.propagateIfPossible(t, IOException.class);
throw new IOException("Unexpected exception", t);
}
}
@Override
public void write(DataOutput out) throws IOException {
out.writeInt(splits.size());
for (AegSplit split : splits) {
WritableUtils.writeString(out, split.getClass().getCanonicalName());
split.write(out);
}
}
@Override
public long getLength() throws IOException, InterruptedException {
int length = 0;
for (AegSplit split : splits) {
length += split.getLength();
}
return length;
}
@Override
public String[] getLocations() throws IOException, InterruptedException {
Set<String> locations = null;
for (AegSplit split : splits) {
Set<String> tempLocations = Sets.newHashSet(split.hosts);
if (locations == null) {
locations = tempLocations;
} else {
locations = Sets.intersection(locations, tempLocations);
}
}
if (locations == null) {
return null;
}
return locations.toArray(new String[0]);
}
public void addSplit(AegSplit split) {
splits.add(split);
}
public List<AegSplit> getSplits() {
return splits;
}
}
| 8,420 |
0 | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/input | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/input/splits/AegCompressedSplit.java | package com.netflix.aegisthus.input.splits;
import com.netflix.aegisthus.io.sstable.compression.CompressionInputStream;
import com.netflix.aegisthus.io.sstable.compression.CompressionMetadata;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.WritableUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import java.io.BufferedInputStream;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.io.InputStream;
public class AegCompressedSplit extends AegSplit {
private static final Logger LOG = LoggerFactory.getLogger(AegCompressedSplit.class);
private Path compressionMetadataPath;
private long compressedLength;
public static AegCompressedSplit createAegCompressedSplit(@Nonnull Path path, long start, long length,
@Nonnull String[] hosts, @Nonnull Path compressionMetadataPath, @Nonnull Configuration conf)
throws IOException {
AegCompressedSplit split = new AegCompressedSplit();
split.path = path;
split.start = start;
split.compressedLength = length;
split.hosts = hosts;
split.compressionMetadataPath = compressionMetadataPath;
CompressionMetadata compressionMetadata = getCompressionMetadata(conf, compressionMetadataPath, length, false);
split.end = compressionMetadata.getDataLength();
LOG.info("start: {}, end: {}", start, split.end);
return split;
}
private static CompressionMetadata getCompressionMetadata(Configuration conf, Path compressionMetadataPath,
long compressedLength, boolean doNonEndCalculations) throws IOException {
FileSystem fs = compressionMetadataPath.getFileSystem(conf);
try (FSDataInputStream cmIn = fs.open(compressionMetadataPath);
BufferedInputStream inputStream = new BufferedInputStream(cmIn)) {
return new CompressionMetadata(inputStream, compressedLength, doNonEndCalculations);
}
}
@Nonnull
@Override
public InputStream getInput(@Nonnull Configuration conf) throws IOException {
CompressionMetadata compressionMetadata = getCompressionMetadata(conf, compressionMetadataPath,
compressedLength, true);
return new CompressionInputStream(super.getInput(conf), compressionMetadata);
}
@Override
public void readFields(@Nonnull DataInput in) throws IOException {
super.readFields(in);
compressionMetadataPath = new Path(WritableUtils.readString(in));
compressedLength = WritableUtils.readVLong(in);
}
@Override
public void write(@Nonnull DataOutput out) throws IOException {
super.write(out);
WritableUtils.writeString(out, compressionMetadataPath.toUri().toString());
WritableUtils.writeVLong(out, compressedLength);
}
}
| 8,421 |
0 | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/input | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/input/splits/AegSplit.java | /**
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.aegisthus.input.splits;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.io.WritableUtils;
import org.apache.hadoop.mapreduce.InputSplit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import java.io.BufferedInputStream;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.DataOutput;
import java.io.IOException;
import java.io.InputStream;
public class AegSplit extends InputSplit implements Writable {
private static final Logger LOG = LoggerFactory.getLogger(AegSplit.class);
protected long end;
protected String[] hosts;
protected Path path;
protected long start;
public static AegSplit createSplit(@Nonnull Path path, long start, long length, @Nonnull String[] hosts) {
AegSplit split = new AegSplit();
split.path = path;
split.start = start;
split.end = length + start;
split.hosts = hosts;
LOG.debug("path: {}, start: {}, end: {}", path, start, split.end);
return split;
}
public long getDataEnd() {
return end;
}
public long getEnd() {
return end;
}
@Nonnull
public InputStream getInput(@Nonnull Configuration conf) throws IOException {
FileSystem fs = path.getFileSystem(conf);
FSDataInputStream fileIn = fs.open(path);
return new DataInputStream(new BufferedInputStream(fileIn));
}
@Override
public long getLength() {
return end - start;
}
@Override
@Nonnull
public String[] getLocations() throws IOException, InterruptedException {
if (hosts == null) {
throw new IllegalStateException("hosts should not be null at this point");
}
return hosts;
}
@Nonnull
public Path getPath() {
if (path == null) {
throw new IllegalStateException("path should not be null at this point");
}
return path;
}
public long getStart() {
return start;
}
@Override
public void readFields(@Nonnull DataInput in) throws IOException {
end = in.readLong();
hosts = WritableUtils.readStringArray(in);
path = new Path(WritableUtils.readString(in));
start = in.readLong();
}
@Override
public void write(@Nonnull DataOutput out) throws IOException {
out.writeLong(end);
WritableUtils.writeStringArray(out, hosts);
WritableUtils.writeString(out, path.toUri().toString());
out.writeLong(start);
}
}
| 8,422 |
0 | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/io | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/io/sstable/IndexDatabaseScanner.java | /**
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.aegisthus.io.sstable;
import org.apache.cassandra.io.util.FileUtils;
import org.apache.commons.io.input.CountingInputStream;
import javax.annotation.Nonnull;
import java.io.Closeable;
import java.io.DataInputStream;
import java.io.IOError;
import java.io.IOException;
import java.io.InputStream;
import java.util.Iterator;
/**
* This class reads an SSTable index file and returns the offset for each key.
*/
public class IndexDatabaseScanner implements Iterator<IndexDatabaseScanner.OffsetInfo>, Closeable {
private final CountingInputStream countingInputStream;
private final DataInputStream input;
public IndexDatabaseScanner(@Nonnull InputStream is) {
this.countingInputStream = new CountingInputStream(is);
this.input = new DataInputStream(this.countingInputStream);
}
@Override
public void close() {
try {
input.close();
} catch (IOException ignored) {
}
}
@Override
public boolean hasNext() {
try {
return input.available() != 0;
} catch (IOException e) {
throw new IOError(e);
}
}
@Override
@Nonnull
public OffsetInfo next() {
try {
long indexOffset = countingInputStream.getByteCount();
int keysize = input.readUnsignedShort();
input.skipBytes(keysize);
Long dataOffset = input.readLong();
skipPromotedIndexes();
return new OffsetInfo(dataOffset, indexOffset);
} catch (IOException e) {
throw new IOError(e);
}
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
void skipPromotedIndexes() throws IOException {
int size = input.readInt();
if (size <= 0) {
return;
}
FileUtils.skipBytesFully(input, size);
}
public static class OffsetInfo {
private final long dataFileOffset;
private final long indexFileOffset;
public OffsetInfo(long dataFileOffset, long indexFileOffset) {
this.dataFileOffset = dataFileOffset;
this.indexFileOffset = indexFileOffset;
}
public long getDataFileOffset() {
return dataFileOffset;
}
@SuppressWarnings("unused")
public long getIndexFileOffset() {
return indexFileOffset;
}
}
}
| 8,423 |
0 | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/io | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/io/sstable/SSTableColumnScanner.java | /**
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.aegisthus.io.sstable;
import com.netflix.aegisthus.io.writable.AtomWritable;
import org.apache.cassandra.db.ColumnSerializer;
import org.apache.cassandra.db.ColumnSerializer.CorruptColumnException;
import org.apache.cassandra.db.OnDiskAtom;
import org.apache.cassandra.db.marshal.BytesType;
import org.apache.cassandra.io.sstable.Descriptor;
import org.apache.cassandra.io.util.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import rx.Observable.OnSubscribe;
import rx.Subscriber;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class SSTableColumnScanner {
private static final Logger LOG = LoggerFactory.getLogger(SSTableColumnScanner.class);
private final long end;
private final OnDiskAtom.Serializer serializer = OnDiskAtom.Serializer.instance;
private final long start;
private DataInputStream input;
private long pos;
private Descriptor.Version version = null;
public SSTableColumnScanner(InputStream is, long start, long end, Descriptor.Version version) throws IOException {
this.version = version;
this.start = start;
this.end = end;
this.input = new DataInputStream(is);
if (this.start > 0) {
LOG.info("skipping to start: {}", start);
skipUnsafe(start);
}
this.pos = start;
}
public void close() {
if (input != null) {
try {
input.close();
} catch (IOException e) {
// ignore
}
input = null;
}
}
void deserialize(Subscriber<? super AtomWritable> subscriber) {
LOG.debug("current pos({}) done ({})", pos, hasMore() ? "has more" : "no more");
while (hasMore()) {
int keysize = -1;
byte[] rowKey = null;
try {
keysize = input.readUnsignedShort();
long rowSize = 2;
rowKey = new byte[keysize];
input.readFully(rowKey);
rowSize += keysize;
if (version.hasRowSizeAndColumnCount) {
rowSize += input.readLong() + 8;
// Since we have the row size in this version we can go ahead and set pos to the end of the row.
this.pos += rowSize;
}
/*
* The local deletion times are similar to the times that they
* were marked for delete, but we only care to know that it was
* deleted at all, so we will go with the long value as the
* timestamps for update are long as well.
*/
@SuppressWarnings({ "unused", "UnusedAssignment" })
int localDeletionTime = input.readInt();
rowSize += 4;
long markedForDeleteAt = input.readLong();
rowSize += 8;
int columnCount = Integer.MAX_VALUE;
if (version.hasRowSizeAndColumnCount) {
columnCount = input.readInt();
}
try {
rowSize += deserializeColumns(subscriber, rowKey, markedForDeleteAt, columnCount, input);
} catch (OutOfMemoryError e) {
String message = "Out of memory while reading row for key " + keyToString(rowKey)
+ "this may be caused by a corrupt file";
subscriber.onError(new IOException(message, e));
} catch (CorruptColumnException e) {
String message = "Error in row for key " + keyToString(rowKey);
subscriber.onError(new IOException(message, e));
}
// For versions without row size we need to load the columns to figure out the size they occupy
if (!version.hasRowSizeAndColumnCount) {
this.pos += rowSize;
}
} catch (OutOfMemoryError e) {
String message = "Out of memory while reading row wth size " + keysize
+ " for key " + keyToString(rowKey) + "this may be caused by a corrupt file";
subscriber.onError(new IOException(message, e));
break;
} catch (IOException e) {
subscriber.onError(e);
break;
}
}
}
private String keyToString(byte[] rowKey) {
if (rowKey == null) {
return "null";
}
String str = BytesType.instance.getString(ByteBuffer.wrap(rowKey));
return StringUtils.left(str, 32);
}
long deserializeColumns(Subscriber<? super AtomWritable> subscriber, byte[] rowKey, long deletedAt,
int count,
DataInput columns) throws IOException {
long columnSize = 0;
int actualColumnCount = 0;
for (int i = 0; i < count; i++, actualColumnCount++) {
// serialize columns
OnDiskAtom atom = serializer.deserializeFromSSTable(
columns, ColumnSerializer.Flag.PRESERVE_SIZE, Integer.MIN_VALUE, version
);
if (atom == null) {
// If atom was null that means this was a version that does not have version.hasRowSizeAndColumnCount
// So we have to add the size for the end of row marker also
columnSize += 2;
break;
}
columnSize += atom.serializedSizeForSSTable();
subscriber.onNext(AtomWritable.createWritable(rowKey, deletedAt, atom));
}
// This is a row with no columns, we still create a writable because we want to preserve this information
if (actualColumnCount == 0) {
subscriber.onNext(AtomWritable.createWritable(rowKey, deletedAt, null));
}
return columnSize;
}
@Override
protected void finalize() throws Throwable {
close();
super.finalize();
}
public long getEnd() {
return end;
}
public long getPos() {
return pos;
}
public long getStart() {
return start;
}
boolean hasMore() {
return pos < end;
}
public rx.Observable<AtomWritable> observable() {
final ExecutorService service = Executors.newSingleThreadExecutor();
rx.Observable<AtomWritable> ret = rx.Observable.create(new OnSubscribe<AtomWritable>() {
@Override
public void call(final Subscriber<? super AtomWritable> subscriber) {
service.execute(new Runnable() {
@Override
public void run() {
deserialize(subscriber);
subscriber.onCompleted();
}
});
}
});
LOG.info("created observable");
return ret;
}
void skipUnsafe(long bytes) throws IOException {
if (bytes <= 0) {
return;
}
FileUtils.skipBytesFully(input, bytes);
}
}
| 8,424 |
0 | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/io/sstable | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/io/sstable/compression/CompressionMetadata.java | /**
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.aegisthus.io.sstable.compression;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.apache.cassandra.exceptions.ConfigurationException;
import org.apache.cassandra.io.compress.CompressionParameters;
import org.apache.cassandra.io.compress.ICompressor;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
public class CompressionMetadata {
private List<Integer> chunkLengths;
private int current;
private long dataLength;
private CompressionParameters parameters;
public CompressionMetadata(InputStream compressionInput, long compressedLength, boolean doNonEndCalculations)
throws IOException {
try (DataInputStream stream = new DataInputStream(compressionInput)) {
String compressorName = stream.readUTF();
int optionCount = stream.readInt();
Map<String, String> options = Maps.newHashMap();
for (int i = 0; i < optionCount; ++i) {
String key = stream.readUTF();
String value = stream.readUTF();
if (doNonEndCalculations) {
options.put(key, value);
}
}
int chunkLength = stream.readInt();
if (doNonEndCalculations) {
try {
parameters = new CompressionParameters(compressorName, chunkLength, options);
} catch (ConfigurationException e) {
throw new RuntimeException("Cannot create CompressionParameters for stored parameters", e);
}
}
setDataLength(stream.readLong());
if (doNonEndCalculations) {
chunkLengths = readChunkLengths(stream, compressedLength);
}
current = 0;
}
}
public int chunkLength() {
return parameters.chunkLength();
}
public ICompressor compressor() {
return parameters.sstableCompressor;
}
public int currentLength() {
if (current < chunkLengths.size()) {
return chunkLengths.get(current);
}
return -1;
}
public long getDataLength() {
return dataLength;
}
public void setDataLength(long dataLength) {
this.dataLength = dataLength;
}
public void incrementChunk() {
current++;
}
private List<Integer> readChunkLengths(DataInput input, long compressedLength) throws IOException {
int chunkCount = input.readInt();
List<Integer> lengths = Lists.newArrayList();
long prev = input.readLong();
for (int i = 1; i < chunkCount; i++) {
long cur = input.readLong();
lengths.add((int) (cur - prev - 4));
prev = cur;
}
lengths.add((int) (compressedLength - prev - 4));
return lengths;
}
}
| 8,425 |
0 | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/io/sstable | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/io/sstable/compression/CompressionInputStream.java | /**
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.aegisthus.io.sstable.compression;
import org.xerial.snappy.SnappyOutputStream;
import javax.annotation.Nonnull;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import static java.lang.Math.min;
/**
* This class implements an input stream for reading Snappy compressed data of
* the format produced by {@link SnappyOutputStream}.
*/
public class CompressionInputStream extends InputStream {
private final byte[] buffer;
private final CompressionMetadata cm;
private final InputStream in;
private final byte[] input;
private boolean closed;
private int position;
private int valid;
/**
* Creates a Snappy input stream to read data from the specified underlying
* input stream.
*
* @param in
* the underlying input stream
*/
public CompressionInputStream(InputStream in, CompressionMetadata cm) {
this.cm = cm;
this.in = in;
//chunkLength*2 because there are some cases where the data is larger than specified
input = new byte[cm.chunkLength() * 2];
buffer = new byte[cm.chunkLength() * 2];
}
@Override
public int available() throws IOException {
if (closed) {
return 0;
}
if (valid > position) {
return valid - position;
}
if (cm.currentLength() <= 0) {
return 0;
}
readInput(cm.currentLength());
cm.incrementChunk();
return valid;
}
@Override
public void close() throws IOException {
try {
in.close();
} finally {
if (!closed) {
closed = true;
}
}
}
private boolean finishedReading() throws IOException {
return available() <= 0;
}
@Override
public int read() throws IOException {
if (closed) {
return -1;
}
if (finishedReading()) {
return -1;
}
return buffer[position++] & 0xFF;
}
@Override
public int read(@Nonnull byte[] output, int offset, int length) throws IOException {
if (closed) {
throw new IOException("Stream is closed");
}
if (length == 0) {
return 0;
}
if (finishedReading()) {
return -1;
}
int size = min(length, available());
System.arraycopy(buffer, position, output, offset, size);
position += size;
return size;
}
private void readInput(int length) throws IOException {
int offset = 0;
while (offset < length) {
int size = in.read(input, offset, length - offset);
if (size == -1) {
throw new EOFException("encountered EOF while reading block data");
}
offset += size;
}
// ignore checksum for now
readChecksum(4);
valid = cm.compressor().uncompress(input, 0, length, buffer, 0);
position = 0;
}
private void readChecksum(int length) throws IOException {
byte[] checksum = new byte[length];
int offset = 0;
while (offset < length) {
int size = in.read(checksum, offset, length - offset);
if (size == -1) {
throw new EOFException("encountered EOF while reading checksum.");
}
offset += size;
}
}
}
| 8,426 |
0 | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/io | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/io/writable/AegisthusKeySortingComparator.java | package com.netflix.aegisthus.io.writable;
import com.google.common.collect.ComparisonChain;
import com.netflix.Aegisthus;
import org.apache.cassandra.db.marshal.AbstractType;
import org.apache.cassandra.db.marshal.TypeParser;
import org.apache.cassandra.exceptions.ConfigurationException;
import org.apache.cassandra.exceptions.SyntaxException;
import org.apache.hadoop.conf.Configurable;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;
import java.nio.ByteBuffer;
import java.util.Comparator;
public class AegisthusKeySortingComparator extends WritableComparator implements Configurable {
private AbstractType<ByteBuffer> columnNameConverter;
private Configuration conf;
private boolean legacyColumnNameFormatting;
private boolean sortColumnsByName;
private AegisthusKey key1 = new AegisthusKey();
private AegisthusKey key2 = new AegisthusKey();
public AegisthusKeySortingComparator() {
super(AegisthusKey.class, false);
}
public static String legacyColumnNameFormat(String columnName) {
return columnName.replaceAll("[\\s\\p{Cntrl}]", " ").replace("\\", "\\\\").replace("\"", "\\\"");
}
@Override
public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
Comparator<ByteBuffer> nameComparator = columnNameConverter;
if (sortColumnsByName) {
nameComparator = new Comparator<ByteBuffer>() {
@Override
public int compare(ByteBuffer o1, ByteBuffer o2) {
if (o1 == null || o2 == null) {
return ComparisonChain.start().compare(o1, o2).result();
}
String c1Name = columnNameConverter.getString(o1);
String c2Name = columnNameConverter.getString(o2);
if (legacyColumnNameFormatting) {
c1Name = legacyColumnNameFormat(c1Name);
c2Name = legacyColumnNameFormat(c2Name);
}
return c1Name.compareTo(c2Name);
}
};
}
key1.readFields(b1, s1, l1);
key2.readFields(b2, s2, l2);
return key1.compareTo(key2, nameComparator);
}
@Override
public Configuration getConf() {
return conf;
}
@Override
public void setConf(Configuration conf) {
this.conf = conf;
String columnType = conf.get(Aegisthus.Feature.CONF_COLUMNTYPE, "BytesType");
legacyColumnNameFormatting = conf.getBoolean(Aegisthus.Feature.CONF_LEGACY_COLUMN_NAME_FORMATTING, false);
sortColumnsByName = conf.getBoolean(Aegisthus.Feature.CONF_SORT_COLUMNS_BY_NAME, false);
try {
//noinspection unchecked
columnNameConverter = (AbstractType<ByteBuffer>) TypeParser.parse(columnType);
} catch (SyntaxException | ConfigurationException e) {
throw new RuntimeException(e);
}
}
}
| 8,427 |
0 | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/io | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/io/writable/AegisthusKeyPartitioner.java | package com.netflix.aegisthus.io.writable;
import org.apache.hadoop.mapreduce.Partitioner;
public class AegisthusKeyPartitioner extends Partitioner<AegisthusKey, AtomWritable> {
@Override
public int getPartition(AegisthusKey key, AtomWritable value, int numPartitions) {
return Math.abs(key.getKey().hashCode() % numPartitions);
}
}
| 8,428 |
0 | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/io | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/io/writable/AegisthusKeyGroupingComparator.java | package com.netflix.aegisthus.io.writable;
import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;
public class AegisthusKeyGroupingComparator extends WritableComparator {
public AegisthusKeyGroupingComparator() {
super(AegisthusKey.class, true);
}
@SuppressWarnings("rawtypes")
@Override
public int compare(WritableComparable wc1, WritableComparable wc2) {
AegisthusKey ck1 = (AegisthusKey) wc1;
AegisthusKey ck2 = (AegisthusKey) wc2;
return ck1.compareTo(ck2);
}
}
| 8,429 |
0 | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/io | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/io/writable/AtomWritable.java | /**
* Copyright 2014 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.aegisthus.io.writable;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.netflix.Aegisthus;
import org.apache.cassandra.db.ColumnSerializer;
import org.apache.cassandra.db.OnDiskAtom;
import org.apache.cassandra.io.sstable.Descriptor.Version;
import org.apache.hadoop.conf.Configurable;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.Writable;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.Objects;
public class AtomWritable implements Writable, Configurable {
private final OnDiskAtom.Serializer serializer = OnDiskAtom.Serializer.instance;
private OnDiskAtom atom;
private Configuration configuration;
private long deletedAt;
private byte[] key;
private Version version;
/**
* Constructs a new AtomWritable for the row/column pair
*
* @param key the row key
* @param deletedAt when the row was deleted, Long.MAX_VALUE if not deleted
* @param atom the on disk representation of this row/column pair
*
* @return a new AtomWritable representing the given row/column pair.
*/
public static AtomWritable createWritable(byte[] key, long deletedAt, OnDiskAtom atom) {
AtomWritable writable = new AtomWritable();
writable.key = key;
writable.deletedAt = deletedAt;
writable.atom = atom;
return writable;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {return true;}
if (obj == null || getClass() != obj.getClass()) {return false;}
final AtomWritable other = (AtomWritable) obj;
return Objects.equals(this.serializer, other.serializer)
&& Objects.equals(this.atom, other.atom)
&& Objects.equals(this.deletedAt, other.deletedAt)
&& Objects.equals(this.key, other.key);
}
public OnDiskAtom getAtom() {
return atom;
}
@Override
public Configuration getConf() {
return configuration;
}
@Override
public void setConf(Configuration conf) {
this.configuration = conf;
String sstableVersion = conf.get(Aegisthus.Feature.CONF_SSTABLE_VERSION);
Preconditions.checkState(!Strings.isNullOrEmpty(sstableVersion), "SSTable version is required configuration");
this.version = new Version(sstableVersion);
}
public long getDeletedAt() {
return deletedAt;
}
public byte[] getKey() {
return key;
}
@Override
public int hashCode() {
return Objects.hash(serializer, atom, deletedAt, key);
}
@Override
public void readFields(DataInput dis) throws IOException {
int length = dis.readInt();
byte[] bytes = new byte[length];
dis.readFully(bytes);
this.key = bytes;
this.deletedAt = dis.readLong();
boolean hasAtom = dis.readBoolean();
if (hasAtom) {
this.atom = serializer.deserializeFromSSTable(
dis, ColumnSerializer.Flag.PRESERVE_SIZE, Integer.MIN_VALUE, version
);
} else {
this.atom = null;
}
}
@Override
public String toString() {
return com.google.common.base.Objects.toStringHelper(this)
.add("key", key)
.add("deletedAt", deletedAt)
.toString();
}
@Override
public void write(DataOutput dos) throws IOException {
dos.writeInt(this.key.length);
dos.write(this.key);
dos.writeLong(this.deletedAt);
if (this.atom != null) {
dos.writeBoolean(true);
serializer.serializeForSSTable(this.atom, dos);
} else {
dos.writeBoolean(false);
}
}
}
| 8,430 |
0 | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/io | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/io/writable/RowWritable.java | /**
* Copyright 2014 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.aegisthus.io.writable;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.netflix.Aegisthus;
import org.apache.cassandra.db.ColumnSerializer;
import org.apache.cassandra.db.OnDiskAtom;
import org.apache.cassandra.io.sstable.Descriptor.Version;
import org.apache.hadoop.conf.Configurable;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.Writable;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.List;
public class RowWritable implements Writable, Configurable {
private final OnDiskAtom.Serializer serializer = OnDiskAtom.Serializer.instance;
private List<OnDiskAtom> columns;
private Configuration configuration;
private long deletedAt;
private Version version;
public static RowWritable createRowWritable(List<OnDiskAtom> columns, long deletedAt) {
RowWritable rowWritable = new RowWritable();
rowWritable.columns = columns;
rowWritable.deletedAt = deletedAt;
return rowWritable;
}
public List<OnDiskAtom> getColumns() {
return columns;
}
@Override
public Configuration getConf() {
return configuration;
}
@Override
public void setConf(Configuration conf) {
this.configuration = conf;
String sstableVersion = conf.get(Aegisthus.Feature.CONF_SSTABLE_VERSION);
Preconditions.checkState(!Strings.isNullOrEmpty(sstableVersion), "SSTable version is required configuration");
this.version = new Version(sstableVersion);
}
public long getDeletedAt() {
return deletedAt;
}
@Override
public void readFields(DataInput in) throws IOException {
deletedAt = in.readLong();
int columnCount = in.readInt();
columns = Lists.newArrayListWithCapacity(columnCount);
for (int i = 0; i < columnCount; i++) {
OnDiskAtom atom = serializer.deserializeFromSSTable(
in, ColumnSerializer.Flag.PRESERVE_SIZE, Integer.MIN_VALUE, version
);
columns.add(atom);
}
}
@Override
public void write(DataOutput out) throws IOException {
out.writeLong(deletedAt);
out.writeInt(columns.size());
for (OnDiskAtom column : columns) {
serializer.serializeForSSTable(column, out);
}
}
}
| 8,431 |
0 | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/io | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/io/writable/AegisthusKey.java | /**
* Copyright 2014 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.aegisthus.io.writable;
import com.google.common.collect.ComparisonChain;
import org.apache.commons.io.Charsets;
import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;
import javax.annotation.Nonnull;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Comparator;
import java.util.Objects;
/**
* This is the key that is output from the map job and input into the reduce job. In most cases it represents a
* key column pair so that the columns are sorted in the same order as they would appear in Cassandra when going into
* the reduce job. This key can also represent a row with no columns. We preserve this information rather than
* deleting these.
*/
public class AegisthusKey implements WritableComparable<AegisthusKey> {
private String sourcePath;
private ByteBuffer key;
private ByteBuffer name;
private Long timestamp;
/**
* This is used to construct an AegisthusKey entry for a row that does not have a column, for example a row with
* all columns deleted.
*
* @param key the row key
*/
public static AegisthusKey createKeyForRow(@Nonnull ByteBuffer key, @Nonnull String sourcePath) {
AegisthusKey aegisthusKey = new AegisthusKey();
aegisthusKey.key = key;
aegisthusKey.sourcePath = sourcePath;
return aegisthusKey;
}
/**
* This is used to construct an AegisthusKey entry for a row that and column pair
*
* @param key the row key
*/
public static AegisthusKey createKeyForRowColumnPair(@Nonnull ByteBuffer key,
@Nonnull String sourcePath,
@Nonnull ByteBuffer name,
long timestamp) {
AegisthusKey aegisthusKey = new AegisthusKey();
aegisthusKey.key = key;
aegisthusKey.sourcePath = sourcePath;
aegisthusKey.name = name;
aegisthusKey.timestamp = timestamp;
return aegisthusKey;
}
@Override
public int compareTo(@Nonnull AegisthusKey other) {
return ComparisonChain.start()
.compare(this.key, other.key)
.compare(this.sourcePath, other.sourcePath)
.result();
}
public int compareTo(@Nonnull AegisthusKey other, Comparator<ByteBuffer> nameComparator) {
// This is a workaround for comparators not handling nulls properly
// The case where name or timestamp is null should only happen when there has been a delete
int result = this.key.compareTo(other.key);
if (result != 0) {
return result;
}
result = this.sourcePath.compareTo(other.sourcePath);
if (result != 0) {
return result;
}
if (this.name == null || this.timestamp == null) {
return -1;
} else if (other.name == null || other.timestamp == null) {
return 1;
}
return ComparisonChain.start()
.compare(this.name, other.name, nameComparator)
.compare(this.timestamp, other.timestamp)
.result();
}
@Override
public boolean equals(Object obj) {
if (this == obj) {return true;}
if (obj == null || getClass() != obj.getClass()) {return false;}
final AegisthusKey other = (AegisthusKey) obj;
return Objects.equals(this.key, other.key)
&& Objects.equals(this.sourcePath, other.sourcePath)
&& Objects.equals(this.name, other.name)
&& Objects.equals(this.timestamp, other.timestamp);
}
@Nonnull
public String getSourcePath() {
return sourcePath;
}
@Nonnull
public ByteBuffer getKey() {
return key;
}
@Override
public int hashCode() {
return Objects.hash(key, sourcePath, name, timestamp);
}
@Override
public void readFields(DataInput dis) throws IOException {
int length = dis.readInt();
byte[] bytes = new byte[length];
dis.readFully(bytes);
this.key = ByteBuffer.wrap(bytes);
// The (possibly empty) sourcePath
length = dis.readInt();
if (length > 0) {
bytes = new byte[length];
dis.readFully(bytes);
this.sourcePath = new String(bytes, Charsets.UTF_8);
} else {
this.sourcePath = "";
}
// Optional column name
length = dis.readInt();
if (length > 0) {
bytes = new byte[length];
dis.readFully(bytes);
this.name = ByteBuffer.wrap(bytes);
} else {
this.name = null;
}
// Optional timestamp
if (dis.readBoolean()) {
this.timestamp = dis.readLong();
} else {
this.timestamp = null;
}
}
/**
* Zero copy readFields.
* Note: As defensive copying is not done, caller should not mutate b1 while using instance.
* */
public void readFields(byte[] bytes, int start, int length) {
int pos = start; // start at the input position
int keyLength = WritableComparator.readInt(bytes, pos);
pos += 4; // move forward by the int that held the key length
this.key = ByteBuffer.wrap(bytes, pos, keyLength);
pos += keyLength; // move forward by the key length
int pathLength = WritableComparator.readInt(bytes, pos);
pos += 4; // move forward by the int that held the path length
if (pathLength > 0) {
this.sourcePath = new String(bytes, pos, pathLength, Charsets.UTF_8);
} else {
this.sourcePath = "";
}
pos += pathLength; // move forward by the path length
int nameLength = WritableComparator.readInt(bytes, pos);
pos += 4; // move forward by an int that held the name length
if (nameLength > 0) {
this.name = ByteBuffer.wrap(bytes, pos, nameLength);
} else {
this.name = null;
}
pos += nameLength; // move forward by the name length
if (bytes[pos] == 0) {
// pos += 1; // move forward by a boolean
this.timestamp = null;
} else {
pos += 1; // move forward by a boolean
this.timestamp = WritableComparator.readLong(bytes, pos);
// pos += 8; // move forward by a long
}
}
@Override
public String toString() {
return com.google.common.base.Objects.toStringHelper(this)
.add("key", key)
.add("name", name)
.add("timestamp", timestamp)
.toString();
}
@Override
public void write(DataOutput dos) throws IOException {
dos.writeInt(key.array().length);
dos.write(key.array());
if (sourcePath.isEmpty()) {
dos.writeInt(0);
} else {
byte[] bytes = sourcePath.getBytes(Charsets.UTF_8);
dos.writeInt(bytes.length);
dos.write(bytes);
}
// Optional column name
if (this.name == null) {
dos.writeInt(0);
} else {
dos.writeInt(name.array().length);
dos.write(name.array());
}
// Optional timestamp
if (this.timestamp != null) {
dos.writeBoolean(true);
dos.writeLong(timestamp);
} else {
dos.writeBoolean(false);
}
}
}
| 8,432 |
0 | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/io | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/io/writable/AegisthusKeyMapper.java | package com.netflix.aegisthus.io.writable;
import org.apache.hadoop.mapreduce.Mapper;
import java.io.IOException;
public class AegisthusKeyMapper extends Mapper<AegisthusKey, AtomWritable, AegisthusKey, AtomWritable> {
@Override
protected void map(AegisthusKey key, AtomWritable value, Context context)
throws IOException, InterruptedException {
context.write(key, value);
}
}
| 8,433 |
0 | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/output/CustomFileNameFileOutputFormat.java | package com.netflix.aegisthus.output;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapreduce.TaskAttemptContext;
import org.apache.hadoop.mapreduce.TaskID;
import org.apache.hadoop.mapreduce.lib.output.FileOutputCommitter;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import java.io.IOException;
import java.text.NumberFormat;
public abstract class CustomFileNameFileOutputFormat<K, V> extends FileOutputFormat<K, V> {
private static final NumberFormat NUMBER_FORMAT = NumberFormat.getInstance();
static {
NUMBER_FORMAT.setMinimumIntegerDigits(5);
NUMBER_FORMAT.setGroupingUsed(false);
}
/**
* Generate a unique filename, based on the task id, name, and extension
* @param context the task that is calling this
* @param name the base filename
* @param extension the filename extension
* @return a string like $name-[jobType]-$id$extension
*/
protected synchronized String getCustomFileName(TaskAttemptContext context,
String name,
String extension) {
TaskID taskId = context.getTaskAttemptID().getTaskID();
int partition = taskId.getId();
return name + '-' + NUMBER_FORMAT.format(partition) + extension;
}
/**
* Get the default path and filename for the output format.
* @param context the task context
* @param extension an extension to add to the filename
* @return a full path $output/_temporary/$task-id/part-[mr]-$id
* @throws java.io.IOException
*/
@Override
public Path getDefaultWorkFile(TaskAttemptContext context, String extension) throws IOException {
FileOutputCommitter committer = (FileOutputCommitter) getOutputCommitter(context);
return new Path(committer.getWorkPath(), getCustomFileName(context, getOutputName(context), extension));
}
}
| 8,434 |
0 | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/output/JsonOutputFormat.java | package com.netflix.aegisthus.output;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerator;
import com.google.common.base.Strings;
import com.google.common.base.Throwables;
import com.netflix.Aegisthus;
import com.netflix.aegisthus.io.writable.AegisthusKey;
import com.netflix.aegisthus.io.writable.AegisthusKeySortingComparator;
import com.netflix.aegisthus.io.writable.RowWritable;
import org.apache.cassandra.db.Column;
import org.apache.cassandra.db.CounterColumn;
import org.apache.cassandra.db.DeletedColumn;
import org.apache.cassandra.db.ExpiringColumn;
import org.apache.cassandra.db.OnDiskAtom;
import org.apache.cassandra.db.RangeTombstone;
import org.apache.cassandra.db.marshal.AbstractType;
import org.apache.cassandra.db.marshal.BytesType;
import org.apache.cassandra.db.marshal.TypeParser;
import org.apache.cassandra.exceptions.ConfigurationException;
import org.apache.cassandra.exceptions.SyntaxException;
import org.apache.cassandra.serializers.MarshalException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapreduce.RecordWriter;
import org.apache.hadoop.mapreduce.TaskAttemptContext;
import org.apache.hadoop.mapreduce.TaskID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.text.NumberFormat;
import java.util.Collections;
import java.util.List;
public class JsonOutputFormat extends CustomFileNameFileOutputFormat<AegisthusKey, RowWritable> {
private static final Logger LOG = LoggerFactory.getLogger(JsonOutputFormat.class);
private static final NumberFormat NUMBER_FORMAT = NumberFormat.getInstance();
static {
NUMBER_FORMAT.setMinimumIntegerDigits(5);
NUMBER_FORMAT.setGroupingUsed(false);
}
@SuppressWarnings("unchecked")
private AbstractType<ByteBuffer> getConverter(Configuration conf, String key) {
String converterType = conf.get(key);
if (Strings.isNullOrEmpty(key)) {
return BytesType.instance;
}
try {
return (AbstractType<ByteBuffer>) TypeParser.parse(converterType);
} catch (SyntaxException | ConfigurationException e) {
throw Throwables.propagate(e);
}
}
@Override
public synchronized String getCustomFileName(TaskAttemptContext context, String name, String extension) {
TaskID taskId = context.getTaskAttemptID().getTaskID();
int partition = taskId.getId();
return "aeg-" + NUMBER_FORMAT.format(partition) + extension;
}
@Override
public RecordWriter<AegisthusKey, RowWritable> getRecordWriter(final TaskAttemptContext context)
throws IOException {
// No extension on the aeg json format files for historical reasons
Path workFile = getDefaultWorkFile(context, "");
Configuration conf = context.getConfiguration();
FileSystem fs = workFile.getFileSystem(conf);
final long maxColSize = conf.getLong(Aegisthus.Feature.CONF_MAXCOLSIZE, -1);
final boolean traceDataFromSource = conf.getBoolean(Aegisthus.Feature.CONF_TRACE_DATA_FROM_SOURCE, false);
final FSDataOutputStream outputStream = fs.create(workFile, false);
final JsonFactory jsonFactory = new JsonFactory();
final AbstractType<ByteBuffer> keyNameConverter = getConverter(conf, Aegisthus.Feature.CONF_KEYTYPE);
final AbstractType<ByteBuffer> columnNameConverter = getConverter(conf, Aegisthus.Feature.CONF_COLUMNTYPE);
final AbstractType<ByteBuffer> columnValueConverter = getConverter(
conf,
Aegisthus.Feature.CONF_COLUMN_VALUE_TYPE
);
final boolean legacyColumnNameFormatting =
conf.getBoolean(Aegisthus.Feature.CONF_LEGACY_COLUMN_NAME_FORMATTING, false);
return new RecordWriter<AegisthusKey, RowWritable>() {
private int errorLogCount = 0;
private String getString(AbstractType<ByteBuffer> converter, ByteBuffer buffer) {
try {
return converter.getString(buffer);
} catch (MarshalException e) {
if (errorLogCount < 100) {
LOG.error("Unable to use converter '{}'", converter, e);
errorLogCount++;
}
return BytesType.instance.getString(buffer);
}
}
private String getString(AbstractType<ByteBuffer> converter, byte[] bytes) {
return getString(converter, ByteBuffer.wrap(bytes));
}
@Override
public void write(AegisthusKey key, RowWritable rowWritable) throws IOException, InterruptedException {
JsonGenerator jsonGenerator = jsonFactory.createGenerator(outputStream);
jsonGenerator.disable(JsonGenerator.Feature.AUTO_CLOSE_TARGET);
String keyName = getString(keyNameConverter, key.getKey().array());
outputStream.writeBytes(keyName);
outputStream.writeByte('\t');
if (traceDataFromSource) {
outputStream.writeBytes(key.getSourcePath());
outputStream.writeByte('\t');
}
jsonGenerator.writeStartObject();
jsonGenerator.writeObjectFieldStart(keyName);
jsonGenerator.writeNumberField("deletedAt", rowWritable.getDeletedAt());
jsonGenerator.writeArrayFieldStart("columns");
List<OnDiskAtom> columns = rowWritable.getColumns();
if (maxColSize != -1) {
long columnSize = 0;
for (OnDiskAtom atom : columns) {
columnSize += atom.serializedSizeForSSTable();
}
// If the column size exceeds the maximum, write out the error message and replace columns with an
// empty list so they will not be output
if (columnSize > maxColSize) {
jsonGenerator.writeString("error");
jsonGenerator.writeString(
String.format("row too large: %,d bytes - limit %,d bytes", columnSize, maxColSize)
);
jsonGenerator.writeNumber(0);
columns = Collections.emptyList();
context.getCounter("aegisthus", "rowsTooBig").increment(1L);
}
}
for (OnDiskAtom atom : columns) {
if (atom instanceof Column) {
jsonGenerator.writeStartArray();
String columnName = getString(columnNameConverter, atom.name());
if (legacyColumnNameFormatting) {
columnName = AegisthusKeySortingComparator.legacyColumnNameFormat(columnName);
}
jsonGenerator.writeString(columnName);
jsonGenerator.writeString(getString(columnValueConverter, ((Column) atom).value()));
jsonGenerator.writeNumber(((Column) atom).timestamp());
if (atom instanceof DeletedColumn) {
jsonGenerator.writeString("d");
} else if (atom instanceof ExpiringColumn) {
jsonGenerator.writeString("e");
jsonGenerator.writeNumber(((ExpiringColumn) atom).getTimeToLive());
jsonGenerator.writeNumber(atom.getLocalDeletionTime());
} else if (atom instanceof CounterColumn) {
jsonGenerator.writeString("c");
jsonGenerator.writeNumber(((CounterColumn) atom).timestampOfLastDelete());
}
jsonGenerator.writeEndArray();
} else if (atom instanceof RangeTombstone) {
LOG.debug("Range Tombstones are not output in the json format");
} else {
throw new IllegalStateException("Unknown atom type for atom: " + atom);
}
}
jsonGenerator.writeEndArray();
jsonGenerator.writeEndObject(); // End key object
jsonGenerator.writeEndObject(); // Outer json
jsonGenerator.close();
outputStream.writeByte('\n');
}
@Override
public void close(TaskAttemptContext context) throws IOException, InterruptedException {
outputStream.close();
}
};
}
}
| 8,435 |
0 | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/output/SSTableOutputFormat.java | package com.netflix.aegisthus.output;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.netflix.Aegisthus;
import com.netflix.aegisthus.io.writable.AegisthusKey;
import com.netflix.aegisthus.io.writable.RowWritable;
import org.apache.cassandra.db.OnDiskAtom;
import org.apache.cassandra.io.sstable.Descriptor.Version;
import org.apache.cassandra.io.sstable.SSTableWriter;
import org.apache.hadoop.conf.Configurable;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapreduce.RecordWriter;
import org.apache.hadoop.mapreduce.TaskAttemptContext;
import org.apache.hadoop.mapreduce.TaskID;
import java.io.IOException;
import java.text.NumberFormat;
public class SSTableOutputFormat extends CustomFileNameFileOutputFormat<AegisthusKey, RowWritable> implements
Configurable {
private static final NumberFormat NUMBER_FORMAT = NumberFormat.getInstance();
static {
NUMBER_FORMAT.setMinimumIntegerDigits(10);
NUMBER_FORMAT.setGroupingUsed(false);
}
private Configuration configuration;
private Version version;
@Override
public Configuration getConf() {
return configuration;
}
@Override
public void setConf(Configuration conf) {
this.configuration = conf;
String sstableVersion = conf.get(Aegisthus.Feature.CONF_SSTABLE_VERSION);
Preconditions.checkState(!Strings.isNullOrEmpty(sstableVersion), "SSTable version is required configuration");
this.version = new Version(sstableVersion);
}
@Override
public synchronized String getCustomFileName(TaskAttemptContext context, String name, String extension) {
TaskID taskId = context.getTaskAttemptID().getTaskID();
int partition = taskId.getId();
String sstableVersion = context.getConfiguration().get(Aegisthus.Feature.CONF_SSTABLE_VERSION);
return context.getConfiguration().get(Aegisthus.Feature.CONF_DATASET, "keyspace-dataset")
+ "-" + sstableVersion
+ "-" + NUMBER_FORMAT.format(partition)
+ "-Data.db";
}
@Override
public RecordWriter<AegisthusKey, RowWritable> getRecordWriter(TaskAttemptContext context) throws IOException {
// No extension on the aeg json format files for historical reasons
Path workFile = getDefaultWorkFile(context, "");
FileSystem fs = workFile.getFileSystem(context.getConfiguration());
final FSDataOutputStream fileOut = fs.create(workFile, false);
final OnDiskAtom.Serializer serializer = OnDiskAtom.Serializer.instance;
return new RecordWriter<AegisthusKey, RowWritable>() {
@Override
public void write(AegisthusKey key, RowWritable rowWritable) throws IOException, InterruptedException {
if (version.hasRowSizeAndColumnCount) {
writeVersion_1_2_5(key, rowWritable);
} else {
writeVersion_2_0(key, rowWritable);
}
}
@Override
public void close(TaskAttemptContext context) throws IOException, InterruptedException {
fileOut.close();
}
void writeVersion_1_2_5(AegisthusKey key, RowWritable row) throws IOException {
byte[] keyBytes = key.getKey().array();
fileOut.writeShort(keyBytes.length);
fileOut.write(keyBytes);
long dataSize = 16; // The bytes for the Int, Long, Int after this loop
for (OnDiskAtom atom : row.getColumns()) {
dataSize += atom.serializedSizeForSSTable();
}
fileOut.writeLong(dataSize);
fileOut.writeInt((int) (row.getDeletedAt() / 1000));
fileOut.writeLong(row.getDeletedAt());
fileOut.writeInt(row.getColumns().size());
for (OnDiskAtom atom : row.getColumns()) {
serializer.serializeForSSTable(atom, fileOut);
}
}
void writeVersion_2_0(AegisthusKey key, RowWritable row) throws IOException {
byte[] keyBytes = key.getKey().array();
fileOut.writeShort(keyBytes.length);
fileOut.write(keyBytes);
fileOut.writeInt((int) (row.getDeletedAt() / 1000));
fileOut.writeLong(row.getDeletedAt());
for (OnDiskAtom atom : row.getColumns()) {
serializer.serializeForSSTable(atom, fileOut);
}
fileOut.writeShort(SSTableWriter.END_OF_ROW);
}
};
}
}
| 8,436 |
0 | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus | Create_ds/aegisthus/aegisthus-hadoop/src/main/java/com/netflix/aegisthus/mapreduce/CassSSTableReducer.java | /**
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.aegisthus.mapreduce;
import com.google.common.collect.Lists;
import com.netflix.Aegisthus;
import com.netflix.aegisthus.io.writable.AegisthusKey;
import com.netflix.aegisthus.io.writable.AtomWritable;
import com.netflix.aegisthus.io.writable.RowWritable;
import org.apache.cassandra.db.Column;
import org.apache.cassandra.db.OnDiskAtom;
import org.apache.cassandra.db.RangeTombstone;
import org.apache.cassandra.db.marshal.AbstractType;
import org.apache.cassandra.db.marshal.TypeParser;
import org.apache.cassandra.exceptions.ConfigurationException;
import org.apache.cassandra.exceptions.SyntaxException;
import org.apache.hadoop.mapreduce.Reducer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Iterator;
import java.util.List;
public class CassSSTableReducer extends Reducer<AegisthusKey, AtomWritable, AegisthusKey, RowWritable> {
private static final Logger LOG = LoggerFactory.getLogger(CassSSTableReducer.class);
private long rowsToAddToCounter = 0;
private AbstractType<?> columnComparator;
private AbstractType<?> rowKeyComparator;
private long maxRowSize = Long.MAX_VALUE;
@Override protected void setup(
Context context)
throws IOException, InterruptedException {
super.setup(context);
maxRowSize = context.getConfiguration().getLong(Aegisthus.Feature.CONF_MAXCOLSIZE, Long.MAX_VALUE);
String columnType = context.getConfiguration().get(Aegisthus.Feature.CONF_COLUMNTYPE, "BytesType");
String rowKeyType = context.getConfiguration().get(Aegisthus.Feature.CONF_KEYTYPE, "BytesType");
try {
columnComparator = TypeParser.parse(columnType);
rowKeyComparator = TypeParser.parse(rowKeyType);
} catch (SyntaxException | ConfigurationException e) {
throw new RuntimeException(e);
}
}
@Override
protected void cleanup(Context context) throws IOException, InterruptedException {
updateCounter(context, true);
super.cleanup(context);
}
@Override
public void reduce(AegisthusKey key, Iterable<AtomWritable> values, Context ctx)
throws IOException, InterruptedException {
RowReducer rowReducer = new RowReducer(columnComparator);
for (AtomWritable value : values) {
if (rowReducer.key == null) {
rowReducer.key = value.getKey();
if (LOG.isDebugEnabled()) {
String formattedKey = rowKeyComparator.getString(ByteBuffer.wrap(rowReducer.key));
LOG.debug("Doing reduce for key '{}'", formattedKey);
}
}
if (value.getDeletedAt() > rowReducer.deletedAt) {
rowReducer.deletedAt = value.getDeletedAt();
}
if (value.getAtom() != null &&
rowReducer.getAtomTotalSize() + value.getAtom().serializedSizeForSSTable() > maxRowSize) {
String formattedKey = rowKeyComparator.getString(ByteBuffer.wrap(rowReducer.key));
LOG.warn("Skipping part of row {} that is too big, current size is already {}.",
formattedKey, rowReducer.getAtomTotalSize());
ctx.getCounter("aegisthus", "reducerRowsTooBig").increment(1L);
break;
}
rowReducer.addAtom(value);
}
rowReducer.finalizeReduce();
ctx.write(key, RowWritable.createRowWritable(rowReducer.columns, rowReducer.deletedAt));
updateCounter(ctx, false);
}
void updateCounter(Context ctx, boolean flushRegardlessOfCount) {
if (flushRegardlessOfCount && rowsToAddToCounter != 0) {
ctx.getCounter("aegisthus", "rows_written").increment(rowsToAddToCounter);
rowsToAddToCounter = 0;
} else {
if (rowsToAddToCounter % 100 == 0) {
ctx.getCounter("aegisthus", "rows_written").increment(rowsToAddToCounter);
rowsToAddToCounter = 0;
}
rowsToAddToCounter++;
}
}
static class RowReducer {
private final List<OnDiskAtom> columns = Lists.newArrayList();
// TODO: need to get comparator
private final RangeTombstone.Tracker tombstoneTracker;
private OnDiskAtom currentColumn = null;
private long deletedAt = Long.MIN_VALUE;
private byte[] key;
private long atomTotalSize = 0L;
RowReducer(AbstractType<?> columnComparator) {
tombstoneTracker = new RangeTombstone.Tracker(columnComparator);
}
@SuppressWarnings("StatementWithEmptyBody")
public void addAtom(AtomWritable writable) {
OnDiskAtom atom = writable.getAtom();
if (atom == null) {
return;
}
atomTotalSize += atom.serializedSizeForSSTable();
this.tombstoneTracker.update(atom);
// Right now, we will only keep columns. This works because we will
// have all the columns a range tombstone applies to when we create
// a snapshot. This will not be true if we go to partial incremental
// processing
if (atom instanceof Column) {
Column column = (Column) atom;
if (this.tombstoneTracker.isDeleted(column)) {
// If the column is deleted by the rangeTombstone, just discard
// it, every other column of the same name will be discarded as
// well, unless it is later than the range tombstone in which
// case the column is out of date anyway
} else if (currentColumn == null) {
currentColumn = column;
} else if (currentColumn.name().equals(column.name())) {
if (column.timestamp() > currentColumn.minTimestamp()) {
currentColumn = column;
}
} else {
columns.add(currentColumn);
currentColumn = column;
}
} else if (atom instanceof RangeTombstone) {
// We do not include these columns in the output since they are deleted
} else {
String error =
"Cassandra added a new type " + atom.getClass().getCanonicalName() + " which we do not support";
throw new IllegalArgumentException(error);
}
}
public void finalizeReduce() {
if (currentColumn != null) {
columns.add(currentColumn);
}
// When cassandra compacts it removes columns that are in deleted rows
// that are older than the deleted timestamp.
// we will duplicate this behavior. If the etl needs this data at some
// point we can change, but it is only available assuming
// cassandra hasn't discarded it.
Iterator<OnDiskAtom> columnIterator = columns.iterator();
while (columnIterator.hasNext()) {
OnDiskAtom atom = columnIterator.next();
if (atom instanceof RangeTombstone) {
columnIterator.remove();
} else if (atom instanceof Column && ((Column) atom).timestamp() <= this.deletedAt) {
columnIterator.remove();
}
}
}
public long getAtomTotalSize() {
return atomTotalSize;
}
}
}
| 8,437 |
0 | Create_ds/aegisthus/aegisthus-pig/src/main/java/com/netflix/aegisthus | Create_ds/aegisthus/aegisthus-pig/src/main/java/com/netflix/aegisthus/pig/AegisthusLoader.java | /**
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.aegisthus.pig;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.RecordReader;
import org.apache.pig.LoadCaster;
import org.apache.pig.LoadMetadata;
import org.apache.pig.ResourceSchema;
import org.apache.pig.ResourceSchema.ResourceFieldSchema;
import org.apache.pig.ResourceStatistics;
import org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigSplit;
import org.apache.pig.builtin.PigStorage;
import org.apache.pig.data.BagFactory;
import org.apache.pig.data.DataType;
import org.apache.pig.data.Tuple;
import org.apache.pig.data.TupleFactory;
import org.apache.pig.impl.logicalLayer.FrontendException;
import org.apache.pig.impl.util.ObjectSerializer;
import org.apache.pig.impl.util.UDFContext;
import org.codehaus.jackson.JsonParseException;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.netflix.aegisthus.tools.AegisthusSerializer;
/**
* Pig loader for aegisthus json format.
*/
public class AegisthusLoader extends PigStorage implements LoadMetadata {
private static final String REQUIRED_COLUMNS = "required.columns";
protected static final BagFactory bagFactory = BagFactory.getInstance();
protected static final TupleFactory tupleFactory = TupleFactory.getInstance();
protected boolean clean = true;
private boolean mRequiredColumnsInitialized = false;
@SuppressWarnings("rawtypes")
protected RecordReader reader = null;
private AegisthusSerializer serializer;
public AegisthusLoader() {
}
public AegisthusLoader(String clean) {
this.clean = Boolean.valueOf(clean);
}
/**
* This function removes all the deleted columns from the data. If the
* columns are deleted via the row being deleted, that will be processed
* prior to the data being available in json.
*/
@SuppressWarnings("unchecked")
private void cleanse(Map<String, Object> map) {
long deletedAt = (Long) map.get(AegisthusSerializer.DELETEDAT);
List<String> delete = Lists.newArrayList();
for (Map.Entry<String, Object> e : map.entrySet()) {
if (!(AegisthusSerializer.KEY.equals(e.getKey()) || AegisthusSerializer.DELETEDAT.equals(e.getKey()))) {
List<Object> values = (List<Object>) e.getValue();
// d in the 4th position indicates the column has been deleted
if (deletedAt > (Long) values.get(2) || (values.size() > 3 && "d".equals(values.get(3)))) {
delete.add(e.getKey());
}
}
}
for (String key : delete) {
map.remove(key);
}
}
@Override
public LoadCaster getLoadCaster() throws IOException {
return new AegisthusLoadCaster();
}
@Override
public Tuple getNext() throws IOException {
if (!mRequiredColumnsInitialized) {
if (signature != null) {
mRequiredColumns = (boolean[]) ObjectSerializer.deserialize(getUdfProperty(REQUIRED_COLUMNS));
}
mRequiredColumnsInitialized = true;
}
if (reader == null) {
return null;
}
if (serializer == null) {
serializer = new AegisthusSerializer();
}
try {
while (reader.nextKeyValue()) {
Text value = (Text) reader.getCurrentValue();
String s = value.toString();
if (s.contains("\t")) {
s = s.split("\t")[1];
}
Map<String, Object> map = serializer.deserialize(s);
if (clean) {
cleanse(map);
// when clean if we have an empty row we will ignore it. The
// map will be size 2 because it will only
// have the key and the deleted ts
// TODO: only remove row if it is empty and is deleted.
if (map.size() == 2) {
continue;
}
}
return tuple(map);
}
} catch (InterruptedException e) {
// ignore
}
return null;
}
@Override
public String[] getPartitionKeys(String arg0, Job arg1) throws IOException {
return null;
}
protected ResourceFieldSchema field(String name, byte type) {
ResourceFieldSchema fs = new ResourceFieldSchema();
fs.setName(name);
fs.setType(type);
return fs;
}
protected ResourceFieldSchema subfield(String name, byte type, ResourceSchema schema) throws IOException {
ResourceFieldSchema fs = new ResourceFieldSchema();
fs.setName(name);
fs.setType(type);
fs.setSchema(schema);
return fs;
}
protected ResourceSchema columnSchema() throws IOException {
ResourceSchema schema = new ResourceSchema();
List<ResourceFieldSchema> fields = new ArrayList<>();
fields.add(field("name", DataType.BYTEARRAY));
fields.add(field("value", DataType.BYTEARRAY));
fields.add(field("ts", DataType.LONG));
fields.add(field("status", DataType.CHARARRAY));
fields.add(field("ttl", DataType.LONG));
ResourceSchema tuple = new ResourceSchema();
tuple.setFields(fields.toArray(new ResourceFieldSchema[0]));
ResourceFieldSchema fs = new ResourceFieldSchema();
fs.setName("column");
fs.setType(DataType.TUPLE);
fs.setSchema(tuple);
fields.clear();
fields.add(fs);
schema.setFields(fields.toArray(new ResourceFieldSchema[0]));
return schema;
}
@Override
public ResourceSchema getSchema(String location, Job job) throws IOException {
ResourceSchema resourceSchema = new ResourceSchema();
List<ResourceFieldSchema> fields = new ArrayList<>();
fields.add(field("key", DataType.BYTEARRAY));
fields.add(field("deletedat", DataType.LONG));
fields.add(subfield("map_columns", DataType.MAP, columnSchema()));
fields.add(subfield("bag_columns", DataType.BAG, columnSchema()));
resourceSchema.setFields(fields.toArray(new ResourceFieldSchema[0]));
return resourceSchema;
}
@Override
public ResourceStatistics getStatistics(String arg0, Job arg1) throws IOException {
return null;
}
protected Properties getUdfContext(String name) {
return UDFContext.getUDFContext().getUDFProperties(this.getClass(), new String[] { name });
}
protected String getUdfProperty(String property) {
return getUdfContext(signature).getProperty(property);
}
@Override
public void prepareToRead(@SuppressWarnings("rawtypes") RecordReader reader, PigSplit split) {
this.reader = reader;
}
@Override
public RequiredFieldResponse pushProjection(RequiredFieldList requiredFieldList) throws FrontendException {
if (requiredFieldList == null)
return null;
if (requiredFieldList.getFields() != null) {
int lastColumn = -1;
for (RequiredField rf : requiredFieldList.getFields()) {
if (rf.getIndex() > lastColumn) {
lastColumn = rf.getIndex();
}
}
mRequiredColumns = new boolean[lastColumn + 1];
for (RequiredField rf : requiredFieldList.getFields()) {
if (rf.getIndex() != -1)
mRequiredColumns[rf.getIndex()] = true;
}
try {
setUdfProperty(REQUIRED_COLUMNS, ObjectSerializer.serialize(mRequiredColumns));
} catch (Exception e) {
throw new RuntimeException("Cannot serialize mRequiredColumns");
}
}
return new RequiredFieldResponse(true);
}
protected boolean required(int pos) {
return (mRequiredColumns == null || (mRequiredColumns.length > pos && mRequiredColumns[pos]));
}
protected void setUdfProperty(String property, String value) {
getUdfContext(signature).setProperty(property, value);
}
@SuppressWarnings("unchecked")
protected Tuple tuple(Map<String, Object> map) throws JsonParseException, IOException {
List<Object> values = new ArrayList<>();
if (required(0)) {
values.add(map.get(AegisthusSerializer.KEY));
}
map.remove(AegisthusSerializer.KEY);
if (required(1)) {
values.add(map.get(AegisthusSerializer.DELETEDAT));
}
map.remove(AegisthusSerializer.DELETEDAT);
// Each item in the map must be a tuple
if (required(2)) {
Map<String, Object> map2 = Maps.newHashMap();
for (Map.Entry<String, Object> e : map.entrySet()) {
map2.put(e.getKey(), tupleFactory.newTuple((List<Object>) e.getValue()));
}
values.add(map2);
}
if (required(3)) {
List<Tuple> cols = Lists.newArrayList();
for (Object obj : map.values()) {
cols.add(tupleFactory.newTuple((List<Object>) obj));
}
values.add(bagFactory.newDefaultBag(cols));
}
return tupleFactory.newTuple(values);
}
}
| 8,438 |
0 | Create_ds/aegisthus/aegisthus-pig/src/main/java/com/netflix/aegisthus | Create_ds/aegisthus/aegisthus-pig/src/main/java/com/netflix/aegisthus/pig/AegisthusLoadCaster.java | /**
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.aegisthus.pig;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.rmi.UnexpectedException;
import java.util.Map;
import org.apache.commons.codec.binary.Hex;
import org.apache.pig.LoadCaster;
import org.apache.pig.ResourceSchema.ResourceFieldSchema;
import org.apache.pig.data.DataBag;
import org.apache.pig.data.Tuple;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class AegisthusLoadCaster implements LoadCaster {
private static Logger LOG = LoggerFactory.getLogger(AegisthusLoadCaster.class);
private static final Hex hex = new Hex();
@Override
public DataBag bytesToBag(byte[] arg0, ResourceFieldSchema arg1) throws IOException {
throw new IOException("Don't do that");
}
@Override
public String bytesToCharArray(byte[] arg0) throws IOException {
if (arg0 == null || arg0.length == 0) {
return null;
}
try {
return new String(hex.decode(arg0));
} catch (Exception e) {
LOG.error("failed to convert " + new String(arg0) + " to chararray");
return null;
}
}
@Override
public Double bytesToDouble(byte[] arg0) throws IOException {
if (arg0 == null || arg0.length == 0) {
return null;
}
try {
byte[] by = hex.decode(arg0);
ByteBuffer bb = ByteBuffer.allocate(by.length);
bb.put(by);
bb.position(0);
return bb.getDouble();
} catch (Exception e) {
LOG.error("failed to convert " + new String(arg0) + " to double");
return null;
}
}
@Override
public Float bytesToFloat(byte[] arg0) throws IOException {
if (arg0 == null || arg0.length == 0) {
return null;
}
try {
byte[] by = hex.decode(arg0);
ByteBuffer bb = ByteBuffer.allocate(by.length);
bb.put(by);
bb.position(0);
return bb.getFloat();
} catch (Exception e) {
LOG.error("failed to convert " + new String(arg0) + " to float");
return null;
}
}
@Override
public Integer bytesToInteger(byte[] arg0) throws IOException {
if (arg0 == null || arg0.length == 0) {
return null;
}
try {
return Integer.valueOf(bytesToCharArray(arg0));
} catch (Exception e) {
}
try {
return (int) getNumber(arg0);
} catch (Exception e) {
LOG.error("failed to convert " + new String(arg0) + " to int");
return null;
}
}
private long getNumber(byte[] arg0) throws Exception {
byte[] by = hex.decode(arg0);
ByteBuffer bb = ByteBuffer.allocate(by.length);
bb.put(by);
bb.position(0);
switch(by.length) {
case 1:
return (long)bb.get();
case 2:
return (long)bb.getShort();
case 4:
return (long)bb.getInt();
case 8:
return (long)bb.getLong();
}
throw new UnexpectedException("couldn't determine datatype");
}
@Override
public Long bytesToLong(byte[] arg0) throws IOException {
if (arg0 == null || arg0.length == 0) {
return null;
}
try {
return Long.valueOf(bytesToCharArray(arg0));
} catch (Exception e) {
}
try {
return getNumber(arg0);
} catch (Exception e) {
LOG.error("failed to convert " + new String(arg0) + " to long");
return null;
}
}
@Override
@Deprecated
public Map<String, Object> bytesToMap(byte[] arg0) throws IOException {
throw new IOException("Don't do that");
}
@Override
public Tuple bytesToTuple(byte[] arg0, ResourceFieldSchema arg1) throws IOException {
throw new IOException("Don't do that");
}
@Override
public Map<String, Object> bytesToMap(byte[] arg0, ResourceFieldSchema arg1) throws IOException {
throw new IOException("Don't do that");
}
@Override
public Boolean bytesToBoolean(byte[] arg0) throws IOException {
throw new IOException("Doesn't handle boolean");
}
@Override
public DateTime bytesToDateTime(byte[] arg0) throws IOException {
throw new IOException("Doesn't handle DateTime");
}
}
| 8,439 |
0 | Create_ds/aegisthus/aegisthus-distcp/src/main | Create_ds/aegisthus/aegisthus-distcp/src/main/java/Distcp.java | import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.GnuParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Partitioner;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.util.StringUtils;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;
import com.google.common.collect.Lists;
import com.netflix.aegisthus.tools.DirectoryWalker;
import com.netflix.aegisthus.tools.StorageHelper;
import com.netflix.aegisthus.tools.Utils;
import com.netflix.hadoop.output.CleanOutputFormat;
public class Distcp extends Configured implements Tool {
public static class Map extends Mapper<LongWritable, Text, LongWritable, Text> {
private long count = 0;
@Override
protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
context.write(new LongWritable(count++), value);
}
}
public static class Partition extends Partitioner<LongWritable, Text> {
@Override
public int getPartition(LongWritable arg0, Text arg1, int arg2) {
return Long.valueOf(arg0.get()).intValue() % arg2;
}
}
public static class Reduce extends Reducer<LongWritable, Text, Text, Text> {
@Override
protected void reduce(LongWritable key, Iterable<Text> values, Context ctx) throws IOException,
InterruptedException {
StorageHelper helper = new StorageHelper(ctx);
boolean snappy = ctx.getConfiguration().getBoolean(CFG_PREFIX + OPT_PRIAM, false);
String base = ctx.getConfiguration().get(CFG_PREFIX + OPT_RECURSIVE);
if (base != null && !base.endsWith("/")) {
base = base + "/";
}
for (Text file : values) {
String fileString = cleanS3(file.toString().trim());
if (base == null) {
helper.copyToTemp(fileString, snappy);
} else {
String prefix = fileString.substring(base.length());
prefix = prefix.replaceAll("/[^/]+$", "");
helper.copyToTemp(fileString, prefix, snappy);
}
}
}
}
private static final String OPT_DISTCP_TARGET = "distcp.target";
private static final String OPT_INPUT_FILE = "input";
private static final String OPT_MANIFEST_OUT = "manifestOut";
private static final String OPT_MANIFEST_IN = "manifest";
private static final String OPT_OVERWRITE = "overwrite";
private static final String OPT_PRIAM = "priam";
private static final String OPT_RECURSIVE = "recursive";
private static final String CFG_PREFIX = "distcp.";
private static final Log LOG = LogFactory.getLog(Distcp.class);
private static final int MAX_REDUCERS = 800;
private static final String OUTPUT = "output";
@SuppressWarnings("static-access")
public static CommandLine getOptions(String[] args) {
Options opts = new Options();
opts.addOption(OptionBuilder
.withArgName(OPT_INPUT_FILE)
.withDescription("Each input location")
.hasArgs()
.create(OPT_INPUT_FILE));
opts.addOption(OptionBuilder
.withArgName(OPT_PRIAM)
.withDescription("the input is snappy stream compressed and should be decompressed (priam backup)")
.create(OPT_PRIAM));
opts.addOption(OptionBuilder
.withArgName(OPT_RECURSIVE)
.withDescription("retain directory structure under this directory")
.hasArg()
.create(OPT_RECURSIVE));
opts.addOption(OptionBuilder
.withArgName(OPT_MANIFEST_IN)
.withDescription("a manifest of the files to be copied")
.hasArg()
.create(OPT_MANIFEST_IN));
opts.addOption(OptionBuilder
.withArgName(OPT_MANIFEST_IN)
.withDescription("a manifest of the files to be copied")
.hasArg()
.create(OPT_MANIFEST_IN));
opts.addOption(OptionBuilder
.withArgName(OPT_MANIFEST_OUT)
.withDescription("write out a manifest file of movement")
.create(OPT_MANIFEST_OUT));
opts.addOption(OptionBuilder
.withArgName(OPT_OVERWRITE)
.withDescription("overwrite the target directory if it exists.")
.create(OPT_OVERWRITE));
opts.addOption(OptionBuilder
.withArgName(OUTPUT)
.isRequired()
.withDescription("output location")
.hasArg()
.create(OUTPUT));
CommandLineParser parser = new GnuParser();
try {
CommandLine cl = parser.parse(opts, args, true);
if (cl.hasOption(OPT_MANIFEST_IN) && cl.hasOption(OPT_INPUT_FILE)) {
System.out.println("Cannot have both a manifest and input files");
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp(String.format("hadoop jar distcp.jar %s", Distcp.class.getName()), opts);
return null;
}
return cl;
} catch (ParseException e) {
System.out.println("Unexpected exception:" + e.getMessage());
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp(String.format("hadoop jar distcp.jar %s", Distcp.class.getName()), opts);
return null;
}
}
public static void main(String[] args) throws Exception {
int res = ToolRunner.run(new Configuration(), new Distcp(), args);
System.exit(res);
}
/**
* checks to see if the output directory exists and throws an error if it
* does.
*
* TODO: extend this to allow overwrite if set.
*
* @throws IOException
*/
protected void checkOutputDirectory(Job job, String outputDir, boolean overwrite) throws IOException {
Path out = new Path(outputDir);
FileSystem fsOut = out.getFileSystem(job.getConfiguration());
if (fsOut.exists(out)) {
if (overwrite) {
fsOut.delete(out, true);
} else {
String error = String.format("Ouput directory (%s) exists, failing", outputDir);
LOG.error(error);
throw new IOException(error);
}
}
}
protected List<FileStatus> getInputs() {
return null;
}
protected Job initializeJob() throws IOException {
Job job = new Job(getConf());
job.setJarByClass(Distcp.class);
job.setInputFormatClass(TextInputFormat.class);
job.setOutputFormatClass(CleanOutputFormat.class);
job.setMapOutputKeyClass(LongWritable.class);
job.setMapOutputValueClass(Text.class);
job.setMapperClass(Map.class);
job.setReducerClass(Reduce.class);
job.setPartitionerClass(Partition.class);
StorageHelper sh = new StorageHelper(job.getConfiguration());
LOG.info(String.format("temp location for job: %s", sh.getBaseTempLocation()));
return job;
}
protected static final String cleanS3(String file) {
return file.replaceFirst("s3://", "s3n://");
}
protected void setupTempDirs() {
}
protected void setReducers(Job job, int fileCount) {
int reducers = job.getConfiguration().getInt("mapred.reduce.tasks", 1);
LOG.info(String.format("fileCount: %d - set reducers: %d", fileCount, reducers));
if (reducers == 1) {
job.getConfiguration().setInt("mapred.reduce.tasks", Math.min(fileCount, MAX_REDUCERS));
} else {
job.getConfiguration().setInt("mapred.reduce.tasks", Math.min(fileCount, reducers));
}
}
protected int setupInput(Job job, Path inputPath, String[] inputFiles, String manifestPath) throws IOException {
int size = 0;
if (manifestPath == null) {
LOG.info("Setting up input");
FileSystem fs = inputPath.getFileSystem(job.getConfiguration());
DataOutputStream dos = fs.create(inputPath);
List<String> inputs = new ArrayList<>();
for (int i = 0; i < inputFiles.length; i++) {
Path path = new Path(cleanS3(inputFiles[i]));
FileStatus[] files = path.getFileSystem(job.getConfiguration()).globStatus(path);
for (int j = 0; j < files.length; j++) {
inputs.add(files[j].getPath().toString());
}
}
List<FileStatus> files = Lists.newArrayList(DirectoryWalker
.with(job.getConfiguration())
.addAll(inputs)
.statuses());
for (FileStatus file : files) {
Path filePath = file.getPath();
// Secondary indexes have the form <keyspace>-<table>.<index_name>-jb-4-Data.db
// while normal files have the form <keyspace>-<table>-jb-4-Data.db .
if (filePath.getName().split("\\.").length > 2) {
LOG.info("Skipping path " + filePath + " as it appears to be a secondary index");
continue;
}
dos.writeBytes(file.getPath().toUri().toString());
dos.write('\n');
size = size + 1;
}
dos.close();
} else {
Utils.copy(new Path(manifestPath), inputPath, false, job.getConfiguration());
FileSystem fs = inputPath.getFileSystem(job.getConfiguration());
BufferedReader br = new BufferedReader(new InputStreamReader(fs.open(inputPath)));
String l;
while ((l = br.readLine()) != null) {
LOG.info(String.format("inputfile: %s", l));
size++;
}
}
return size;
}
@Override
public int run(String[] args) throws Exception {
CommandLine cl = getOptions(args);
if (cl == null) {
return 1;
}
Job job = initializeJob();
String outputDir = cl.getOptionValue(OUTPUT);
StorageHelper helper = new StorageHelper(job.getConfiguration());
helper.setFinalPath(outputDir);
checkOutputDirectory(job, outputDir, cl.hasOption(OPT_OVERWRITE));
job.getConfiguration().setBoolean(CFG_PREFIX + OPT_PRIAM, cl.hasOption(OPT_PRIAM));
if (cl.hasOption(OPT_RECURSIVE)) {
job.getConfiguration().set(CFG_PREFIX + OPT_RECURSIVE, cleanS3(cl.getOptionValue(OPT_RECURSIVE)));
}
String pathTemp = String.format("/tmp/%s", UUID.randomUUID().toString());
LOG.info(String.format("writing to %s", pathTemp));
Path tmp = new Path("/tmp");
FileSystem fs = tmp.getFileSystem(job.getConfiguration());
fs.mkdirs(new Path(pathTemp));
Path inputPath = new Path(new Path(pathTemp), "input.txt");
Path tmpPath = new Path(new Path(pathTemp), "out");
int fileCount = setupInput( job,
inputPath,
cl.getOptionValues(OPT_INPUT_FILE),
cl.getOptionValue(OPT_MANIFEST_IN));
setReducers(job, fileCount);
TextInputFormat.setInputPaths(job, inputPath.toUri().toString());
FileOutputFormat.setOutputPath(job, tmpPath);
boolean success = runJob(job, cl);
// TODO: output manifest
/*
* if (success && cl.hasOption(OPT_MANIFEST_OUT)) { writeManifest(job,
* files); }
*/
fs.delete(new Path(pathTemp), true);
return success ? 0 : 1;
}
protected boolean runJob(Job job, CommandLine cl) throws IOException, InterruptedException, ClassNotFoundException {
job.submit();
System.out.println(job.getJobID());
System.out.println(job.getTrackingURL());
return job.waitForCompletion(true);
}
protected void writeManifest(Job job, List<FileStatus> files) throws IOException {
Path out = new Path(job.getConfiguration().get(OPT_DISTCP_TARGET));
FileSystem fsOut = out.getFileSystem(job.getConfiguration());
DataOutputStream dos = fsOut.create(new Path(out, "_manifest/.manifest"));
for (FileStatus file : files) {
Path output = new Path(out, file.getPath().getName());
dos.writeBytes(output.toUri().toString());
dos.write('\n');
}
dos.close();
}
}
| 8,440 |
0 | Create_ds/aegisthus/aegisthus-distcp/src/main/java/com/netflix/hadoop | Create_ds/aegisthus/aegisthus-distcp/src/main/java/com/netflix/hadoop/output/CleanOutputFormat.java | package com.netflix.hadoop.output;
import java.io.IOException;
import org.apache.hadoop.mapreduce.JobContext;
import org.apache.hadoop.mapreduce.OutputCommitter;
import org.apache.hadoop.mapreduce.OutputFormat;
import org.apache.hadoop.mapreduce.RecordWriter;
import org.apache.hadoop.mapreduce.TaskAttemptContext;
public class CleanOutputFormat<K, V> extends OutputFormat<K, V> {
public static class CleanOutputRecordWriter<K, V> extends RecordWriter<K, V> {
@Override
public void close(TaskAttemptContext arg0) throws IOException, InterruptedException {
// TODO Auto-generated method stub
}
@Override
public void write(K arg0, V arg1) throws IOException, InterruptedException {
// TODO Auto-generated method stub
}
}
@Override
public synchronized OutputCommitter getOutputCommitter(TaskAttemptContext arg0) throws IOException {
return new CleanOutputCommitter();
}
@Override
public void checkOutputSpecs(JobContext arg0) throws IOException, InterruptedException {
}
@Override
public RecordWriter<K, V> getRecordWriter(TaskAttemptContext arg0) throws IOException, InterruptedException {
// TODO Auto-generated method stub
return new CleanOutputRecordWriter<K, V>();
}
}
| 8,441 |
0 | Create_ds/aegisthus/aegisthus-distcp/src/main/java/com/netflix/hadoop | Create_ds/aegisthus/aegisthus-distcp/src/main/java/com/netflix/hadoop/output/CleanOutputCommitter.java | package com.netflix.hadoop.output;
import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.mapreduce.JobContext;
import org.apache.hadoop.mapreduce.JobStatus.State;
import org.apache.hadoop.mapreduce.OutputCommitter;
import org.apache.hadoop.mapreduce.TaskAttemptContext;
import com.netflix.aegisthus.tools.StorageHelper;
public class CleanOutputCommitter extends OutputCommitter {
private static final Log LOG = LogFactory.getLog(CleanOutputCommitter.class);;
@Override
public void abortTask(TaskAttemptContext ctx) throws IOException {
// NOOP - everything will be cleaned up by the job at the end.
// Things that are written out will be handled by future attempts
}
@Override
public void abortJob(JobContext job, State state) throws IOException {
LOG.info("aborting job");
StorageHelper sh = new StorageHelper(job.getConfiguration());
try {
LOG.info("deleting committed files");
sh.deleteCommitted();
} finally {
LOG.info("deleting temp files");
sh.deleteBaseTempLocation();
}
}
@Override
public void commitJob(JobContext job) throws IOException {
LOG.info("committing job");
StorageHelper sh = new StorageHelper(job.getConfiguration());
sh.deleteBaseTempLocation();
}
@Override
public void commitTask(TaskAttemptContext ctx) throws IOException {
LOG.info("committing task");
StorageHelper sh = new StorageHelper(ctx);
sh.moveTaskOutputToFinal();
}
@Override
public boolean needsTaskCommit(TaskAttemptContext ctx) throws IOException {
if (ctx.getTaskAttemptID().isMap()) {
return false;
}
return true;
}
@Override
public void setupJob(JobContext job) throws IOException {
StorageHelper sh = new StorageHelper(job.getConfiguration());
LOG.info(String.format("temp location for job: %s", sh.getBaseTempLocation()));
}
@Override
public void setupTask(TaskAttemptContext ctx) throws IOException {
StorageHelper sh = new StorageHelper(ctx);
LOG.info(String.format("temp location for task: %s", sh.getBaseTaskAttemptTempLocation()));
}
}
| 8,442 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/ModelDoNotUseInToString.java | package com.airbnb.epoxy;
import com.airbnb.epoxy.EpoxyAttribute.Option;
public class ModelDoNotUseInToString extends EpoxyModel<Object> {
@EpoxyAttribute int value;
@EpoxyAttribute({Option.DoNotUseInToString}) int value2;
@EpoxyAttribute({Option.DoNotUseInToString}) String value3;
@Override
protected int getDefaultLayout() {
return 0;
}
} | 8,443 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/SavedStateView.java | package com.airbnb.epoxy;
import android.content.Context;
import android.view.View;
@ModelView(defaultLayout = 1, saveViewState = true)
public class SavedStateView extends View {
public SavedStateView(Context context) {
super(context);
}
@ModelProp
public void setClickListener(String title) {
}
} | 8,444 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/TestAfterBindPropsViewModel_.java | package com.airbnb.epoxy;
import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;
import java.lang.CharSequence;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
/**
* Generated file. Do not modify!
*/
public class TestAfterBindPropsViewModel_ extends EpoxyModel<TestAfterBindPropsView> implements GeneratedModel<TestAfterBindPropsView>, TestAfterBindPropsViewModelBuilder {
private OnModelBoundListener<TestAfterBindPropsViewModel_, TestAfterBindPropsView> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<TestAfterBindPropsViewModel_, TestAfterBindPropsView> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<TestAfterBindPropsViewModel_, TestAfterBindPropsView> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<TestAfterBindPropsViewModel_, TestAfterBindPropsView> onModelVisibilityChangedListener_epoxyGeneratedModel;
private boolean flag_Boolean = false;
private boolean flagSuper_Boolean = false;
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final TestAfterBindPropsView object,
final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void bind(final TestAfterBindPropsView object) {
super.bind(object);
object.setFlagSuper(flagSuper_Boolean);
object.setFlag(flag_Boolean);
}
@Override
public void bind(final TestAfterBindPropsView object, EpoxyModel previousModel) {
if (!(previousModel instanceof TestAfterBindPropsViewModel_)) {
bind(object);
return;
}
TestAfterBindPropsViewModel_ that = (TestAfterBindPropsViewModel_) previousModel;
super.bind(object);
if ((flagSuper_Boolean != that.flagSuper_Boolean)) {
object.setFlagSuper(flagSuper_Boolean);
}
if ((flag_Boolean != that.flag_Boolean)) {
object.setFlag(flag_Boolean);
}
}
@Override
public void handlePostBind(final TestAfterBindPropsView object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
object.afterFlagSet();
object.afterFlagSetSuper();
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public TestAfterBindPropsViewModel_ onBind(
OnModelBoundListener<TestAfterBindPropsViewModel_, TestAfterBindPropsView> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(TestAfterBindPropsView object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public TestAfterBindPropsViewModel_ onUnbind(
OnModelUnboundListener<TestAfterBindPropsViewModel_, TestAfterBindPropsView> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState, final TestAfterBindPropsView object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public TestAfterBindPropsViewModel_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<TestAfterBindPropsViewModel_, TestAfterBindPropsView> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final TestAfterBindPropsView object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public TestAfterBindPropsViewModel_ onVisibilityChanged(
OnModelVisibilityChangedListener<TestAfterBindPropsViewModel_, TestAfterBindPropsView> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
/**
* <i>Optional</i>: Default value is false
*
* @see TestAfterBindPropsView#setFlag(boolean)
*/
public TestAfterBindPropsViewModel_ flag(boolean flag) {
onMutation();
this.flag_Boolean = flag;
return this;
}
public boolean flag() {
return flag_Boolean;
}
/**
* <i>Optional</i>: Default value is false
*
* @see TestAfterBindPropsSuperView#setFlagSuper(boolean)
*/
public TestAfterBindPropsViewModel_ flagSuper(boolean flagSuper) {
onMutation();
this.flagSuper_Boolean = flagSuper;
return this;
}
public boolean flagSuper() {
return flagSuper_Boolean;
}
@Override
public TestAfterBindPropsViewModel_ id(long id) {
super.id(id);
return this;
}
@Override
public TestAfterBindPropsViewModel_ id(@Nullable Number... ids) {
super.id(ids);
return this;
}
@Override
public TestAfterBindPropsViewModel_ id(long id1, long id2) {
super.id(id1, id2);
return this;
}
@Override
public TestAfterBindPropsViewModel_ id(@Nullable CharSequence key) {
super.id(key);
return this;
}
@Override
public TestAfterBindPropsViewModel_ id(@Nullable CharSequence key,
@Nullable CharSequence... otherKeys) {
super.id(key, otherKeys);
return this;
}
@Override
public TestAfterBindPropsViewModel_ id(@Nullable CharSequence key, long id) {
super.id(key, id);
return this;
}
@Override
public TestAfterBindPropsViewModel_ layout(@LayoutRes int layoutRes) {
super.layout(layoutRes);
return this;
}
@Override
public TestAfterBindPropsViewModel_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback spanSizeCallback) {
super.spanSizeOverride(spanSizeCallback);
return this;
}
@Override
public TestAfterBindPropsViewModel_ show() {
super.show();
return this;
}
@Override
public TestAfterBindPropsViewModel_ show(boolean show) {
super.show(show);
return this;
}
@Override
public TestAfterBindPropsViewModel_ hide() {
super.hide();
return this;
}
@Override
@LayoutRes
protected int getDefaultLayout() {
return 1;
}
@Override
public TestAfterBindPropsViewModel_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
this.flag_Boolean = false;
this.flagSuper_Boolean = false;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof TestAfterBindPropsViewModel_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
TestAfterBindPropsViewModel_ that = (TestAfterBindPropsViewModel_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((flag_Boolean != that.flag_Boolean)) {
return false;
}
if ((flagSuper_Boolean != that.flagSuper_Boolean)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (flag_Boolean ? 1 : 0);
_result = 31 * _result + (flagSuper_Boolean ? 1 : 0);
return _result;
}
@Override
public String toString() {
return "TestAfterBindPropsViewModel_{" +
"flag_Boolean=" + flag_Boolean +
", flagSuper_Boolean=" + flagSuper_Boolean +
"}" + super.toString();
}
@Override
public int getSpanSize(int totalSpanCount, int position, int itemCount) {
return totalSpanCount;
}
}
| 8,445 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/ModelWithConstructors_.java | package com.airbnb.epoxy;
import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;
import java.lang.CharSequence;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
/**
* Generated file. Do not modify!
*/
public class ModelWithConstructors_ extends ModelWithConstructors implements GeneratedModel<Object>, ModelWithConstructorsBuilder {
private OnModelBoundListener<ModelWithConstructors_, Object> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<ModelWithConstructors_, Object> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<ModelWithConstructors_, Object> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<ModelWithConstructors_, Object> onModelVisibilityChangedListener_epoxyGeneratedModel;
public ModelWithConstructors_(long id, int valueInt) {
super(id, valueInt);
}
public ModelWithConstructors_(int valueInt) {
super(valueInt);
}
public ModelWithConstructors_() {
super();
}
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final Object object, final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void handlePostBind(final Object object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ModelWithConstructors_ onBind(
OnModelBoundListener<ModelWithConstructors_, Object> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(Object object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ModelWithConstructors_ onUnbind(
OnModelUnboundListener<ModelWithConstructors_, Object> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState, final Object object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ModelWithConstructors_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<ModelWithConstructors_, Object> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final Object object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ModelWithConstructors_ onVisibilityChanged(
OnModelVisibilityChangedListener<ModelWithConstructors_, Object> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
public ModelWithConstructors_ valueInt(int valueInt) {
onMutation();
super.valueInt = valueInt;
return this;
}
public int valueInt() {
return valueInt;
}
@Override
public ModelWithConstructors_ id(long id) {
super.id(id);
return this;
}
@Override
public ModelWithConstructors_ id(@Nullable Number... ids) {
super.id(ids);
return this;
}
@Override
public ModelWithConstructors_ id(long id1, long id2) {
super.id(id1, id2);
return this;
}
@Override
public ModelWithConstructors_ id(@Nullable CharSequence key) {
super.id(key);
return this;
}
@Override
public ModelWithConstructors_ id(@Nullable CharSequence key,
@Nullable CharSequence... otherKeys) {
super.id(key, otherKeys);
return this;
}
@Override
public ModelWithConstructors_ id(@Nullable CharSequence key, long id) {
super.id(key, id);
return this;
}
@Override
public ModelWithConstructors_ layout(@LayoutRes int layoutRes) {
super.layout(layoutRes);
return this;
}
@Override
public ModelWithConstructors_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback spanSizeCallback) {
super.spanSizeOverride(spanSizeCallback);
return this;
}
@Override
public ModelWithConstructors_ show() {
super.show();
return this;
}
@Override
public ModelWithConstructors_ show(boolean show) {
super.show(show);
return this;
}
@Override
public ModelWithConstructors_ hide() {
super.hide();
return this;
}
@Override
public ModelWithConstructors_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
super.valueInt = 0;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof ModelWithConstructors_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
ModelWithConstructors_ that = (ModelWithConstructors_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((valueInt != that.valueInt)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + valueInt;
return _result;
}
@Override
public String toString() {
return "ModelWithConstructors_{" +
"valueInt=" + valueInt +
"}" + super.toString();
}
}
| 8,446 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodParentStillNoLayout.java | package com.airbnb.epoxy;
public class GenerateDefaultLayoutMethodParentStillNoLayout {
@EpoxyModelClass
public static abstract class NoLayout extends StillNoLayout {
@EpoxyAttribute int value;
}
@EpoxyModelClass
public static abstract class StillNoLayout extends EpoxyModel<Object> {
}
} | 8,447 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/ModelWithPrivateFieldWithoutGetter.java | package com.airbnb.epoxy;
public class ModelWithPrivateFieldWithoutGetter extends EpoxyModel<Object> {
@EpoxyAttribute private int valueInt;
@Override
protected int getDefaultLayout() {
return 0;
}
public void setValueInt(int valueInt) {
this.valueInt = valueInt;
}
} | 8,448 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/ModelConfigSubPackageOverridesParent.java | package com.airbnb.epoxy.configtest.sub;
import com.airbnb.epoxy.EpoxyAttribute;
import com.airbnb.epoxy.EpoxyModel;
public class ModelConfigSubPackageOverridesParent extends EpoxyModel<Object> {
public static class ClassWithoutHashCode {
}
@EpoxyAttribute ClassWithoutHashCode classWithoutHashCode;
@Override
protected int getDefaultLayout() {
return 0;
}
} | 8,449 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/TestAfterBindPropsView.java | package com.airbnb.epoxy;
import android.content.Context;
@ModelView(defaultLayout = 1)
public class TestAfterBindPropsView extends TestAfterBindPropsSuperView {
public TestAfterBindPropsView(Context context) {
super(context);
}
@ModelProp
public void setFlag(boolean flag) {
}
@AfterPropsSet
public void afterFlagSet() {
}
} | 8,450 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/TextPropDefaultView_throwsForNonStringRes.java | package com.airbnb.epoxy;
import android.content.Context;
import androidx.annotation.Nullable;
import android.view.View;
@ModelView(defaultLayout = 1)
public class TextPropDefaultView_throwsForNonStringRes extends View {
public TextPropDefaultView_throwsForNonStringRes(Context context) {
super(context);
}
@TextProp(defaultRes = R.layout.res)
public void textWithDefault(CharSequence title) {
}
}
| 8,451 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/ModelRequiresHashCodeAutoValueClassPasses.java | package com.airbnb.epoxy.configtest;
import com.airbnb.epoxy.EpoxyAttribute;
import com.airbnb.epoxy.EpoxyModel;
import com.google.auto.value.AutoValue;
public class ModelRequiresHashCodeAutoValueClassPasses extends EpoxyModel<Object> {
@AutoValue
public static abstract class AutoValueClass {
}
@EpoxyAttribute AutoValueClass autoValueClass;
@Override
protected int getDefaultLayout() {
return 0;
}
} | 8,452 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/OnViewRecycledView_throwsIfPrivate.java | package com.airbnb.epoxy;
import android.content.Context;
import android.view.View;
@ModelView(defaultLayout = 1)
public class OnViewRecycledView_throwsIfPrivate extends View {
public OnViewRecycledView_throwsIfPrivate(Context context) {
super(context);
}
@ModelProp
public void setTitle(CharSequence title) {
}
@OnViewRecycled
private void onRecycled1() {
}
} | 8,453 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/ModelWithIntDef_.java | package com.airbnb.epoxy.models;
import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;
import com.airbnb.epoxy.EpoxyController;
import com.airbnb.epoxy.EpoxyModel;
import com.airbnb.epoxy.EpoxyViewHolder;
import com.airbnb.epoxy.GeneratedModel;
import com.airbnb.epoxy.OnModelBoundListener;
import com.airbnb.epoxy.OnModelUnboundListener;
import com.airbnb.epoxy.OnModelVisibilityChangedListener;
import com.airbnb.epoxy.OnModelVisibilityStateChangedListener;
import com.airbnb.epoxy.models.ModelWithIntDef.MyType;
import java.lang.CharSequence;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
/**
* Generated file. Do not modify!
*/
public class ModelWithIntDef_ extends ModelWithIntDef implements GeneratedModel<Object>, ModelWithIntDefBuilder {
private OnModelBoundListener<ModelWithIntDef_, Object> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<ModelWithIntDef_, Object> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<ModelWithIntDef_, Object> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<ModelWithIntDef_, Object> onModelVisibilityChangedListener_epoxyGeneratedModel;
public ModelWithIntDef_() {
super();
}
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final Object object, final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void handlePostBind(final Object object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ModelWithIntDef_ onBind(OnModelBoundListener<ModelWithIntDef_, Object> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(Object object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ModelWithIntDef_ onUnbind(OnModelUnboundListener<ModelWithIntDef_, Object> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState, final Object object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ModelWithIntDef_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<ModelWithIntDef_, Object> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final Object object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ModelWithIntDef_ onVisibilityChanged(
OnModelVisibilityChangedListener<ModelWithIntDef_, Object> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
public ModelWithIntDef_ type(@MyType int type) {
onMutation();
super.type = type;
return this;
}
@MyType
public int type() {
return type;
}
@Override
public ModelWithIntDef_ id(long id) {
super.id(id);
return this;
}
@Override
public ModelWithIntDef_ id(@Nullable Number... ids) {
super.id(ids);
return this;
}
@Override
public ModelWithIntDef_ id(long id1, long id2) {
super.id(id1, id2);
return this;
}
@Override
public ModelWithIntDef_ id(@Nullable CharSequence key) {
super.id(key);
return this;
}
@Override
public ModelWithIntDef_ id(@Nullable CharSequence key, @Nullable CharSequence... otherKeys) {
super.id(key, otherKeys);
return this;
}
@Override
public ModelWithIntDef_ id(@Nullable CharSequence key, long id) {
super.id(key, id);
return this;
}
@Override
public ModelWithIntDef_ layout(@LayoutRes int layoutRes) {
super.layout(layoutRes);
return this;
}
@Override
public ModelWithIntDef_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback spanSizeCallback) {
super.spanSizeOverride(spanSizeCallback);
return this;
}
@Override
public ModelWithIntDef_ show() {
super.show();
return this;
}
@Override
public ModelWithIntDef_ show(boolean show) {
super.show(show);
return this;
}
@Override
public ModelWithIntDef_ hide() {
super.hide();
return this;
}
@Override
public ModelWithIntDef_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
super.type = 0;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof ModelWithIntDef_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
ModelWithIntDef_ that = (ModelWithIntDef_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((type != that.type)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + type;
return _result;
}
@Override
public String toString() {
return "ModelWithIntDef_{" +
"type=" + type +
"}" + super.toString();
}
}
| 8,454 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/ModelRequiresHashCodeEnumPasses.java | package com.airbnb.epoxy.configtest;
import com.airbnb.epoxy.EpoxyAttribute;
import com.airbnb.epoxy.EpoxyModel;
public class ModelRequiresHashCodeEnumPasses extends EpoxyModel<Object> {
public enum MyEnum {
Value
}
@EpoxyAttribute MyEnum enumValue;
@Override
protected int getDefaultLayout() {
return 0;
}
} | 8,455 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/TestFieldPropChildView.java | package com.airbnb.epoxy;
import android.content.Context;
import com.airbnb.epoxy.ModelView;
import com.airbnb.epoxy.TextProp;
@ModelView(autoLayout = ModelView.Size.WRAP_WIDTH_WRAP_HEIGHT)
public class TestFieldPropChildView extends TestFieldPropParentView {
@TextProp CharSequence textValue;
public TestFieldPropChildView(Context context) {
super(context);
}
} | 8,456 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/TestFieldPropIgnoreRequireHashCodeOptionView.java | package com.airbnb.epoxy;
import android.content.Context;
import android.view.View;
import com.airbnb.epoxy.AfterPropsSet;
import com.airbnb.epoxy.ModelProp;
import com.airbnb.epoxy.ModelProp.Option;
import com.airbnb.epoxy.ModelView;
@ModelView(autoLayout = ModelView.Size.WRAP_WIDTH_WRAP_HEIGHT)
public class TestFieldPropIgnoreRequireHashCodeOptionView extends View {
@ModelProp(options = Option.IgnoreRequireHashCode) OnClickListener value;
public TestFieldPropIgnoreRequireHashCodeOptionView(Context context) {
super(context);
}
@AfterPropsSet
public void call() {
}
}
| 8,457 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/ModelWithPrivateViewClickListener_.java | package com.airbnb.epoxy;
import android.view.View;
import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;
import java.lang.CharSequence;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
/**
* Generated file. Do not modify!
*/
public class ModelWithPrivateViewClickListener_ extends ModelWithPrivateViewClickListener implements GeneratedModel<Object>, ModelWithPrivateViewClickListenerBuilder {
private OnModelBoundListener<ModelWithPrivateViewClickListener_, Object> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<ModelWithPrivateViewClickListener_, Object> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<ModelWithPrivateViewClickListener_, Object> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<ModelWithPrivateViewClickListener_, Object> onModelVisibilityChangedListener_epoxyGeneratedModel;
public ModelWithPrivateViewClickListener_() {
super();
}
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final Object object, final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void handlePostBind(final Object object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ModelWithPrivateViewClickListener_ onBind(
OnModelBoundListener<ModelWithPrivateViewClickListener_, Object> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(Object object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ModelWithPrivateViewClickListener_ onUnbind(
OnModelUnboundListener<ModelWithPrivateViewClickListener_, Object> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState, final Object object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ModelWithPrivateViewClickListener_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<ModelWithPrivateViewClickListener_, Object> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final Object object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ModelWithPrivateViewClickListener_ onVisibilityChanged(
OnModelVisibilityChangedListener<ModelWithPrivateViewClickListener_, Object> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
/**
* Set a click listener that will provide the parent view, model, and adapter position of the clicked view. This will clear the normal View.OnClickListener if one has been set
*/
public ModelWithPrivateViewClickListener_ clickListener(
final OnModelClickListener<ModelWithPrivateViewClickListener_, Object> clickListener) {
onMutation();
if (clickListener == null) {
super.setClickListener(null);
}
else {
super.setClickListener(new WrappedEpoxyModelClickListener<>(clickListener));
}
return this;
}
public ModelWithPrivateViewClickListener_ clickListener(View.OnClickListener clickListener) {
onMutation();
super.setClickListener(clickListener);
return this;
}
public View.OnClickListener clickListener() {
return super.getClickListener();
}
@Override
public ModelWithPrivateViewClickListener_ id(long id) {
super.id(id);
return this;
}
@Override
public ModelWithPrivateViewClickListener_ id(@Nullable Number... ids) {
super.id(ids);
return this;
}
@Override
public ModelWithPrivateViewClickListener_ id(long id1, long id2) {
super.id(id1, id2);
return this;
}
@Override
public ModelWithPrivateViewClickListener_ id(@Nullable CharSequence key) {
super.id(key);
return this;
}
@Override
public ModelWithPrivateViewClickListener_ id(@Nullable CharSequence key,
@Nullable CharSequence... otherKeys) {
super.id(key, otherKeys);
return this;
}
@Override
public ModelWithPrivateViewClickListener_ id(@Nullable CharSequence key, long id) {
super.id(key, id);
return this;
}
@Override
public ModelWithPrivateViewClickListener_ layout(@LayoutRes int layoutRes) {
super.layout(layoutRes);
return this;
}
@Override
public ModelWithPrivateViewClickListener_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback spanSizeCallback) {
super.spanSizeOverride(spanSizeCallback);
return this;
}
@Override
public ModelWithPrivateViewClickListener_ show() {
super.show();
return this;
}
@Override
public ModelWithPrivateViewClickListener_ show(boolean show) {
super.show(show);
return this;
}
@Override
public ModelWithPrivateViewClickListener_ hide() {
super.hide();
return this;
}
@Override
public ModelWithPrivateViewClickListener_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
super.setClickListener(null);
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof ModelWithPrivateViewClickListener_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
ModelWithPrivateViewClickListener_ that = (ModelWithPrivateViewClickListener_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((getClickListener() == null) != (that.getClickListener() == null))) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (getClickListener() != null ? 1 : 0);
return _result;
}
@Override
public String toString() {
return "ModelWithPrivateViewClickListener_{" +
"clickListener=" + getClickListener() +
"}" + super.toString();
}
}
| 8,458 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethod.java | package com.airbnb.epoxy;
@EpoxyModelClass(layout = 1)
public abstract class GenerateDefaultLayoutMethod extends EpoxyModel<Object> {
@EpoxyAttribute int value;
} | 8,459 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/ModelWithPrivateFieldWithStaticSetter.java | package com.airbnb.epoxy;
public class ModelWithPrivateFieldWithStaticSetter extends EpoxyModel<Object> {
@EpoxyAttribute private int valueInt;
@Override
protected int getDefaultLayout() {
return 0;
}
public int getValueInt() {
return valueInt;
}
public static void setValueInt(int valueInt) {
}
} | 8,460 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/ModelWithAllPrivateFieldTypes_.java | package com.airbnb.epoxy;
import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;
import java.lang.Boolean;
import java.lang.Byte;
import java.lang.CharSequence;
import java.lang.Character;
import java.lang.Double;
import java.lang.Float;
import java.lang.Integer;
import java.lang.Long;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.Short;
import java.lang.String;
import java.util.Arrays;
import java.util.List;
/**
* Generated file. Do not modify!
*/
public class ModelWithAllPrivateFieldTypes_ extends ModelWithAllPrivateFieldTypes implements GeneratedModel<Object>, ModelWithAllPrivateFieldTypesBuilder {
private OnModelBoundListener<ModelWithAllPrivateFieldTypes_, Object> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<ModelWithAllPrivateFieldTypes_, Object> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<ModelWithAllPrivateFieldTypes_, Object> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<ModelWithAllPrivateFieldTypes_, Object> onModelVisibilityChangedListener_epoxyGeneratedModel;
public ModelWithAllPrivateFieldTypes_() {
super();
}
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final Object object, final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void handlePostBind(final Object object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ModelWithAllPrivateFieldTypes_ onBind(
OnModelBoundListener<ModelWithAllPrivateFieldTypes_, Object> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(Object object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ModelWithAllPrivateFieldTypes_ onUnbind(
OnModelUnboundListener<ModelWithAllPrivateFieldTypes_, Object> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState, final Object object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ModelWithAllPrivateFieldTypes_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<ModelWithAllPrivateFieldTypes_, Object> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final Object object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ModelWithAllPrivateFieldTypes_ onVisibilityChanged(
OnModelVisibilityChangedListener<ModelWithAllPrivateFieldTypes_, Object> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
public ModelWithAllPrivateFieldTypes_ valueInt(int valueInt) {
onMutation();
super.setValueInt(valueInt);
return this;
}
public int valueInt() {
return super.getValueInt();
}
public ModelWithAllPrivateFieldTypes_ valueInteger(Integer valueInteger) {
onMutation();
super.setValueInteger(valueInteger);
return this;
}
public Integer valueInteger() {
return super.getValueInteger();
}
public ModelWithAllPrivateFieldTypes_ valueShort(short valueShort) {
onMutation();
super.setValueShort(valueShort);
return this;
}
public short valueShort() {
return super.getValueShort();
}
public ModelWithAllPrivateFieldTypes_ valueShortWrapper(Short valueShortWrapper) {
onMutation();
super.setValueShortWrapper(valueShortWrapper);
return this;
}
public Short valueShortWrapper() {
return super.getValueShortWrapper();
}
public ModelWithAllPrivateFieldTypes_ valueChar(char valueChar) {
onMutation();
super.setValueChar(valueChar);
return this;
}
public char valueChar() {
return super.getValueChar();
}
public ModelWithAllPrivateFieldTypes_ valueCharacter(Character valueCharacter) {
onMutation();
super.setValueCharacter(valueCharacter);
return this;
}
public Character valueCharacter() {
return super.getValueCharacter();
}
public ModelWithAllPrivateFieldTypes_ valuebByte(byte valuebByte) {
onMutation();
super.setValuebByte(valuebByte);
return this;
}
public byte valuebByte() {
return super.getValuebByte();
}
public ModelWithAllPrivateFieldTypes_ valueByteWrapper(Byte valueByteWrapper) {
onMutation();
super.setValueByteWrapper(valueByteWrapper);
return this;
}
public Byte valueByteWrapper() {
return super.getValueByteWrapper();
}
public ModelWithAllPrivateFieldTypes_ valueLong(long valueLong) {
onMutation();
super.setValueLong(valueLong);
return this;
}
public long valueLong() {
return super.getValueLong();
}
public ModelWithAllPrivateFieldTypes_ valueLongWrapper(Long valueLongWrapper) {
onMutation();
super.setValueLongWrapper(valueLongWrapper);
return this;
}
public Long valueLongWrapper() {
return super.getValueLongWrapper();
}
public ModelWithAllPrivateFieldTypes_ valueDouble(double valueDouble) {
onMutation();
super.setValueDouble(valueDouble);
return this;
}
public double valueDouble() {
return super.getValueDouble();
}
public ModelWithAllPrivateFieldTypes_ valueDoubleWrapper(Double valueDoubleWrapper) {
onMutation();
super.setValueDoubleWrapper(valueDoubleWrapper);
return this;
}
public Double valueDoubleWrapper() {
return super.getValueDoubleWrapper();
}
public ModelWithAllPrivateFieldTypes_ valueFloat(float valueFloat) {
onMutation();
super.setValueFloat(valueFloat);
return this;
}
public float valueFloat() {
return super.getValueFloat();
}
public ModelWithAllPrivateFieldTypes_ valueFloatWrapper(Float valueFloatWrapper) {
onMutation();
super.setValueFloatWrapper(valueFloatWrapper);
return this;
}
public Float valueFloatWrapper() {
return super.getValueFloatWrapper();
}
public ModelWithAllPrivateFieldTypes_ valueBoolean(boolean valueBoolean) {
onMutation();
super.setValueBoolean(valueBoolean);
return this;
}
public boolean valueBoolean() {
return super.isValueBoolean();
}
public ModelWithAllPrivateFieldTypes_ valueBooleanWrapper(Boolean valueBooleanWrapper) {
onMutation();
super.setValueBooleanWrapper(valueBooleanWrapper);
return this;
}
public Boolean valueBooleanWrapper() {
return super.getValueBooleanWrapper();
}
public ModelWithAllPrivateFieldTypes_ valueIntArray(int[] valueIntArray) {
onMutation();
super.setValueIntArray(valueIntArray);
return this;
}
public int[] valueIntArray() {
return super.getValueIntArray();
}
public ModelWithAllPrivateFieldTypes_ valueObjectArray(Object[] valueObjectArray) {
onMutation();
super.setValueObjectArray(valueObjectArray);
return this;
}
public Object[] valueObjectArray() {
return super.getValueObjectArray();
}
public ModelWithAllPrivateFieldTypes_ valueString(String valueString) {
onMutation();
super.setValueString(valueString);
return this;
}
public String valueString() {
return super.getValueString();
}
public ModelWithAllPrivateFieldTypes_ valueObject(Object valueObject) {
onMutation();
super.setValueObject(valueObject);
return this;
}
public Object valueObject() {
return super.getValueObject();
}
public ModelWithAllPrivateFieldTypes_ valueList(List<String> valueList) {
onMutation();
super.setValueList(valueList);
return this;
}
public List<String> valueList() {
return super.getValueList();
}
@Override
public ModelWithAllPrivateFieldTypes_ getValueObject() {
super.getValueObject();
return this;
}
@Override
public ModelWithAllPrivateFieldTypes_ id(long id) {
super.id(id);
return this;
}
@Override
public ModelWithAllPrivateFieldTypes_ id(@Nullable Number... ids) {
super.id(ids);
return this;
}
@Override
public ModelWithAllPrivateFieldTypes_ id(long id1, long id2) {
super.id(id1, id2);
return this;
}
@Override
public ModelWithAllPrivateFieldTypes_ id(@Nullable CharSequence key) {
super.id(key);
return this;
}
@Override
public ModelWithAllPrivateFieldTypes_ id(@Nullable CharSequence key,
@Nullable CharSequence... otherKeys) {
super.id(key, otherKeys);
return this;
}
@Override
public ModelWithAllPrivateFieldTypes_ id(@Nullable CharSequence key, long id) {
super.id(key, id);
return this;
}
@Override
public ModelWithAllPrivateFieldTypes_ layout(@LayoutRes int layoutRes) {
super.layout(layoutRes);
return this;
}
@Override
public ModelWithAllPrivateFieldTypes_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback spanSizeCallback) {
super.spanSizeOverride(spanSizeCallback);
return this;
}
@Override
public ModelWithAllPrivateFieldTypes_ show() {
super.show();
return this;
}
@Override
public ModelWithAllPrivateFieldTypes_ show(boolean show) {
super.show(show);
return this;
}
@Override
public ModelWithAllPrivateFieldTypes_ hide() {
super.hide();
return this;
}
@Override
public ModelWithAllPrivateFieldTypes_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
super.setValueInt(0);
super.setValueInteger(null);
super.setValueShort((short) 0);
super.setValueShortWrapper(null);
super.setValueChar((char) 0);
super.setValueCharacter(null);
super.setValuebByte((byte) 0);
super.setValueByteWrapper(null);
super.setValueLong(0L);
super.setValueLongWrapper(null);
super.setValueDouble(0.0d);
super.setValueDoubleWrapper(null);
super.setValueFloat(0.0f);
super.setValueFloatWrapper(null);
super.setValueBoolean(false);
super.setValueBooleanWrapper(null);
super.setValueIntArray(null);
super.setValueObjectArray(null);
super.setValueString(null);
super.setValueObject(null);
super.setValueList(null);
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof ModelWithAllPrivateFieldTypes_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
ModelWithAllPrivateFieldTypes_ that = (ModelWithAllPrivateFieldTypes_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((getValueInt() != that.getValueInt())) {
return false;
}
if ((getValueInteger() != null ? !getValueInteger().equals(that.getValueInteger()) : that.getValueInteger() != null)) {
return false;
}
if ((getValueShort() != that.getValueShort())) {
return false;
}
if ((getValueShortWrapper() != null ? !getValueShortWrapper().equals(that.getValueShortWrapper()) : that.getValueShortWrapper() != null)) {
return false;
}
if ((getValueChar() != that.getValueChar())) {
return false;
}
if ((getValueCharacter() != null ? !getValueCharacter().equals(that.getValueCharacter()) : that.getValueCharacter() != null)) {
return false;
}
if ((getValuebByte() != that.getValuebByte())) {
return false;
}
if ((getValueByteWrapper() != null ? !getValueByteWrapper().equals(that.getValueByteWrapper()) : that.getValueByteWrapper() != null)) {
return false;
}
if ((getValueLong() != that.getValueLong())) {
return false;
}
if ((getValueLongWrapper() != null ? !getValueLongWrapper().equals(that.getValueLongWrapper()) : that.getValueLongWrapper() != null)) {
return false;
}
if ((Double.compare(that.getValueDouble(), getValueDouble()) != 0)) {
return false;
}
if ((getValueDoubleWrapper() != null ? !getValueDoubleWrapper().equals(that.getValueDoubleWrapper()) : that.getValueDoubleWrapper() != null)) {
return false;
}
if ((Float.compare(that.getValueFloat(), getValueFloat()) != 0)) {
return false;
}
if ((getValueFloatWrapper() != null ? !getValueFloatWrapper().equals(that.getValueFloatWrapper()) : that.getValueFloatWrapper() != null)) {
return false;
}
if ((isValueBoolean() != that.isValueBoolean())) {
return false;
}
if ((getValueBooleanWrapper() != null ? !getValueBooleanWrapper().equals(that.getValueBooleanWrapper()) : that.getValueBooleanWrapper() != null)) {
return false;
}
if (!Arrays.equals(getValueIntArray(), that.getValueIntArray())) {
return false;
}
if (!Arrays.equals(getValueObjectArray(), that.getValueObjectArray())) {
return false;
}
if ((getValueString() != null ? !getValueString().equals(that.getValueString()) : that.getValueString() != null)) {
return false;
}
if ((getValueObject() != null ? !getValueObject().equals(that.getValueObject()) : that.getValueObject() != null)) {
return false;
}
if ((getValueList() != null ? !getValueList().equals(that.getValueList()) : that.getValueList() != null)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
long temp;
_result = 31 * _result + getValueInt();
_result = 31 * _result + (getValueInteger() != null ? getValueInteger().hashCode() : 0);
_result = 31 * _result + getValueShort();
_result = 31 * _result + (getValueShortWrapper() != null ? getValueShortWrapper().hashCode() : 0);
_result = 31 * _result + getValueChar();
_result = 31 * _result + (getValueCharacter() != null ? getValueCharacter().hashCode() : 0);
_result = 31 * _result + getValuebByte();
_result = 31 * _result + (getValueByteWrapper() != null ? getValueByteWrapper().hashCode() : 0);
_result = 31 * _result + (int) (getValueLong() ^ (getValueLong() >>> 32));
_result = 31 * _result + (getValueLongWrapper() != null ? getValueLongWrapper().hashCode() : 0);
temp = Double.doubleToLongBits(getValueDouble());
_result = 31 * _result + (int) (temp ^ (temp >>> 32));
_result = 31 * _result + (getValueDoubleWrapper() != null ? getValueDoubleWrapper().hashCode() : 0);
_result = 31 * _result + (getValueFloat() != +0.0f ? Float.floatToIntBits(getValueFloat()) : 0);
_result = 31 * _result + (getValueFloatWrapper() != null ? getValueFloatWrapper().hashCode() : 0);
_result = 31 * _result + (isValueBoolean() ? 1 : 0);
_result = 31 * _result + (getValueBooleanWrapper() != null ? getValueBooleanWrapper().hashCode() : 0);
_result = 31 * _result + Arrays.hashCode(getValueIntArray());
_result = 31 * _result + Arrays.hashCode(getValueObjectArray());
_result = 31 * _result + (getValueString() != null ? getValueString().hashCode() : 0);
_result = 31 * _result + (getValueObject() != null ? getValueObject().hashCode() : 0);
_result = 31 * _result + (getValueList() != null ? getValueList().hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "ModelWithAllPrivateFieldTypes_{" +
"valueInt=" + getValueInt() +
", valueInteger=" + getValueInteger() +
", valueShort=" + getValueShort() +
", valueShortWrapper=" + getValueShortWrapper() +
", valueChar=" + getValueChar() +
", valueCharacter=" + getValueCharacter() +
", valuebByte=" + getValuebByte() +
", valueByteWrapper=" + getValueByteWrapper() +
", valueLong=" + getValueLong() +
", valueLongWrapper=" + getValueLongWrapper() +
", valueDouble=" + getValueDouble() +
", valueDoubleWrapper=" + getValueDoubleWrapper() +
", valueFloat=" + getValueFloat() +
", valueFloatWrapper=" + getValueFloatWrapper() +
", valueBoolean=" + isValueBoolean() +
", valueBooleanWrapper=" + getValueBooleanWrapper() +
", valueIntArray=" + getValueIntArray() +
", valueObjectArray=" + getValueObjectArray() +
", valueString=" + getValueString() +
", valueObject=" + getValueObject() +
", valueList=" + getValueList() +
"}" + super.toString();
}
}
| 8,461 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/ControllerWithAutoModelWithSuperClass$SubControllerWithAutoModelWithSuperClass_EpoxyHelper.java | package com.airbnb.epoxy.adapter;
import com.airbnb.epoxy.BasicModelWithAttribute_;
import com.airbnb.epoxy.ControllerHelper;
import com.airbnb.epoxy.EpoxyModel;
import java.lang.IllegalStateException;
import java.lang.Override;
import java.lang.String;
/**
* Generated file. Do not modify!
*/
public class ControllerWithAutoModelWithSuperClass$SubControllerWithAutoModelWithSuperClass_EpoxyHelper extends ControllerHelper<ControllerWithAutoModelWithSuperClass.SubControllerWithAutoModelWithSuperClass> {
private final ControllerWithAutoModelWithSuperClass.SubControllerWithAutoModelWithSuperClass controller;
private EpoxyModel modelWithAttribute3;
private EpoxyModel modelWithAttribute2;
private EpoxyModel modelWithAttribute1;
public ControllerWithAutoModelWithSuperClass$SubControllerWithAutoModelWithSuperClass_EpoxyHelper(
ControllerWithAutoModelWithSuperClass.SubControllerWithAutoModelWithSuperClass controller) {
this.controller = controller;
}
@Override
public void resetAutoModels() {
validateModelsHaveNotChanged();
controller.modelWithAttribute3 = new BasicModelWithAttribute_();
controller.modelWithAttribute3.id(-1);
controller.modelWithAttribute2 = new BasicModelWithAttribute_();
controller.modelWithAttribute2.id(-2);
controller.modelWithAttribute1 = new BasicModelWithAttribute_();
controller.modelWithAttribute1.id(-3);
saveModelsForNextValidation();
}
private void validateModelsHaveNotChanged() {
validateSameModel(modelWithAttribute3, controller.modelWithAttribute3, "modelWithAttribute3", -1);
validateSameModel(modelWithAttribute2, controller.modelWithAttribute2, "modelWithAttribute2", -2);
validateSameModel(modelWithAttribute1, controller.modelWithAttribute1, "modelWithAttribute1", -3);
validateModelHashCodesHaveNotChanged(controller);
}
private void validateSameModel(EpoxyModel expectedObject, EpoxyModel actualObject,
String fieldName, int id) {
if (expectedObject != actualObject) {
throw new IllegalStateException("Fields annotated with AutoModel cannot be directly assigned. The controller manages these fields for you. (" + controller.getClass().getSimpleName() + "#" + fieldName + ")");
}
if (actualObject != null && actualObject.id() != id) {
throw new IllegalStateException("Fields annotated with AutoModel cannot have their id changed manually. The controller manages the ids of these models for you. (" + controller.getClass().getSimpleName() + "#" + fieldName + ")");
}
}
private void saveModelsForNextValidation() {
modelWithAttribute3 = controller.modelWithAttribute3;
modelWithAttribute2 = controller.modelWithAttribute2;
modelWithAttribute1 = controller.modelWithAttribute1;
}
}
| 8,462 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/TestFieldPropGenerateStringOverloadsOptionViewModel_.java | package com.airbnb.epoxy;
import android.content.Context;
import android.view.ViewGroup;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.PluralsRes;
import androidx.annotation.StringRes;
import java.lang.CharSequence;
import java.lang.IllegalArgumentException;
import java.lang.IllegalStateException;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.lang.UnsupportedOperationException;
import java.util.BitSet;
/**
* Generated file. Do not modify!
*/
public class TestFieldPropGenerateStringOverloadsOptionViewModel_ extends EpoxyModel<TestFieldPropGenerateStringOverloadsOptionView> implements GeneratedModel<TestFieldPropGenerateStringOverloadsOptionView>, TestFieldPropGenerateStringOverloadsOptionViewModelBuilder {
private final BitSet assignedAttributes_epoxyGeneratedModel = new BitSet(1);
private OnModelBoundListener<TestFieldPropGenerateStringOverloadsOptionViewModel_, TestFieldPropGenerateStringOverloadsOptionView> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<TestFieldPropGenerateStringOverloadsOptionViewModel_, TestFieldPropGenerateStringOverloadsOptionView> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<TestFieldPropGenerateStringOverloadsOptionViewModel_, TestFieldPropGenerateStringOverloadsOptionView> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<TestFieldPropGenerateStringOverloadsOptionViewModel_, TestFieldPropGenerateStringOverloadsOptionView> onModelVisibilityChangedListener_epoxyGeneratedModel;
/**
* Bitset index: 0
*/
private StringAttributeData value_StringAttributeData = new StringAttributeData();
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
if (!assignedAttributes_epoxyGeneratedModel.get(0)) {
throw new IllegalStateException("A value is required for value");
}
}
@Override
protected int getViewType() {
return 0;
}
@Override
public TestFieldPropGenerateStringOverloadsOptionView buildView(ViewGroup parent) {
TestFieldPropGenerateStringOverloadsOptionView v = new TestFieldPropGenerateStringOverloadsOptionView(parent.getContext());
v.setLayoutParams(new ViewGroup.MarginLayoutParams(ViewGroup.MarginLayoutParams.WRAP_CONTENT, ViewGroup.MarginLayoutParams.WRAP_CONTENT));
return v;
}
@Override
public void handlePreBind(final EpoxyViewHolder holder,
final TestFieldPropGenerateStringOverloadsOptionView object, final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void bind(final TestFieldPropGenerateStringOverloadsOptionView object) {
super.bind(object);
object.value = value_StringAttributeData.toString(object.getContext());
}
@Override
public void bind(final TestFieldPropGenerateStringOverloadsOptionView object,
EpoxyModel previousModel) {
if (!(previousModel instanceof TestFieldPropGenerateStringOverloadsOptionViewModel_)) {
bind(object);
return;
}
TestFieldPropGenerateStringOverloadsOptionViewModel_ that = (TestFieldPropGenerateStringOverloadsOptionViewModel_) previousModel;
super.bind(object);
if ((value_StringAttributeData != null ? !value_StringAttributeData.equals(that.value_StringAttributeData) : that.value_StringAttributeData != null)) {
object.value = value_StringAttributeData.toString(object.getContext());
}
}
@Override
public void handlePostBind(final TestFieldPropGenerateStringOverloadsOptionView object,
int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
object.call();
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public TestFieldPropGenerateStringOverloadsOptionViewModel_ onBind(
OnModelBoundListener<TestFieldPropGenerateStringOverloadsOptionViewModel_, TestFieldPropGenerateStringOverloadsOptionView> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(TestFieldPropGenerateStringOverloadsOptionView object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public TestFieldPropGenerateStringOverloadsOptionViewModel_ onUnbind(
OnModelUnboundListener<TestFieldPropGenerateStringOverloadsOptionViewModel_, TestFieldPropGenerateStringOverloadsOptionView> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState,
final TestFieldPropGenerateStringOverloadsOptionView object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public TestFieldPropGenerateStringOverloadsOptionViewModel_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<TestFieldPropGenerateStringOverloadsOptionViewModel_, TestFieldPropGenerateStringOverloadsOptionView> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth,
final TestFieldPropGenerateStringOverloadsOptionView object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public TestFieldPropGenerateStringOverloadsOptionViewModel_ onVisibilityChanged(
OnModelVisibilityChangedListener<TestFieldPropGenerateStringOverloadsOptionViewModel_, TestFieldPropGenerateStringOverloadsOptionView> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
public CharSequence getValue(Context context) {
return value_StringAttributeData.toString(context);
}
/**
* <i>Required.</i>
*
* @see TestFieldPropGenerateStringOverloadsOptionView#value
*/
public TestFieldPropGenerateStringOverloadsOptionViewModel_ value(@NonNull CharSequence value) {
onMutation();
assignedAttributes_epoxyGeneratedModel.set(0);
if (value == null) {
throw new IllegalArgumentException("value cannot be null");
}
value_StringAttributeData.setValue(value);
return this;
}
/**
* Throws if a value <= 0 is set.
* <p>
* <i>Required.</i>
*
* @see TestFieldPropGenerateStringOverloadsOptionView#value
*/
public TestFieldPropGenerateStringOverloadsOptionViewModel_ value(@StringRes int stringRes) {
onMutation();
assignedAttributes_epoxyGeneratedModel.set(0);
value_StringAttributeData.setValue(stringRes);
return this;
}
/**
* Throws if a value <= 0 is set.
* <p>
* <i>Required.</i>
*
* @see TestFieldPropGenerateStringOverloadsOptionView#value
*/
public TestFieldPropGenerateStringOverloadsOptionViewModel_ value(@StringRes int stringRes,
Object... formatArgs) {
onMutation();
assignedAttributes_epoxyGeneratedModel.set(0);
value_StringAttributeData.setValue(stringRes, formatArgs);
return this;
}
/**
* Throws if a value <= 0 is set.
* <p>
* <i>Required.</i>
*
* @see TestFieldPropGenerateStringOverloadsOptionView#value
*/
public TestFieldPropGenerateStringOverloadsOptionViewModel_ valueQuantityRes(
@PluralsRes int pluralRes, int quantity, Object... formatArgs) {
onMutation();
assignedAttributes_epoxyGeneratedModel.set(0);
value_StringAttributeData.setValue(pluralRes, quantity, formatArgs);
return this;
}
@Override
public TestFieldPropGenerateStringOverloadsOptionViewModel_ id(long id) {
super.id(id);
return this;
}
@Override
public TestFieldPropGenerateStringOverloadsOptionViewModel_ id(@Nullable Number... ids) {
super.id(ids);
return this;
}
@Override
public TestFieldPropGenerateStringOverloadsOptionViewModel_ id(long id1, long id2) {
super.id(id1, id2);
return this;
}
@Override
public TestFieldPropGenerateStringOverloadsOptionViewModel_ id(@Nullable CharSequence key) {
super.id(key);
return this;
}
@Override
public TestFieldPropGenerateStringOverloadsOptionViewModel_ id(@Nullable CharSequence key,
@Nullable CharSequence... otherKeys) {
super.id(key, otherKeys);
return this;
}
@Override
public TestFieldPropGenerateStringOverloadsOptionViewModel_ id(@Nullable CharSequence key,
long id) {
super.id(key, id);
return this;
}
@Override
public TestFieldPropGenerateStringOverloadsOptionViewModel_ layout(@LayoutRes int layoutRes) {
throw new UnsupportedOperationException("Layout resources are unsupported with programmatic views.");
}
@Override
public TestFieldPropGenerateStringOverloadsOptionViewModel_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback spanSizeCallback) {
super.spanSizeOverride(spanSizeCallback);
return this;
}
@Override
public TestFieldPropGenerateStringOverloadsOptionViewModel_ show() {
super.show();
return this;
}
@Override
public TestFieldPropGenerateStringOverloadsOptionViewModel_ show(boolean show) {
super.show(show);
return this;
}
@Override
public TestFieldPropGenerateStringOverloadsOptionViewModel_ hide() {
super.hide();
return this;
}
@Override
@LayoutRes
protected int getDefaultLayout() {
throw new UnsupportedOperationException("Layout resources are unsupported for views created programmatically.");
}
@Override
public TestFieldPropGenerateStringOverloadsOptionViewModel_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
assignedAttributes_epoxyGeneratedModel.clear();
this.value_StringAttributeData = new StringAttributeData();
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof TestFieldPropGenerateStringOverloadsOptionViewModel_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
TestFieldPropGenerateStringOverloadsOptionViewModel_ that = (TestFieldPropGenerateStringOverloadsOptionViewModel_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((value_StringAttributeData != null ? !value_StringAttributeData.equals(that.value_StringAttributeData) : that.value_StringAttributeData != null)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (value_StringAttributeData != null ? value_StringAttributeData.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "TestFieldPropGenerateStringOverloadsOptionViewModel_{" +
"value_StringAttributeData=" + value_StringAttributeData +
"}" + super.toString();
}
@Override
public int getSpanSize(int totalSpanCount, int position, int itemCount) {
return totalSpanCount;
}
}
| 8,463 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/ModelWithoutHash_.java | package com.airbnb.epoxy;
import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;
import java.lang.CharSequence;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
/**
* Generated file. Do not modify!
*/
public class ModelWithoutHash_ extends ModelWithoutHash implements GeneratedModel<Object>, ModelWithoutHashBuilder {
private OnModelBoundListener<ModelWithoutHash_, Object> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<ModelWithoutHash_, Object> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<ModelWithoutHash_, Object> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<ModelWithoutHash_, Object> onModelVisibilityChangedListener_epoxyGeneratedModel;
public ModelWithoutHash_() {
super();
}
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final Object object, final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void handlePostBind(final Object object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ModelWithoutHash_ onBind(OnModelBoundListener<ModelWithoutHash_, Object> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(Object object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ModelWithoutHash_ onUnbind(OnModelUnboundListener<ModelWithoutHash_, Object> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState, final Object object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ModelWithoutHash_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<ModelWithoutHash_, Object> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final Object object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ModelWithoutHash_ onVisibilityChanged(
OnModelVisibilityChangedListener<ModelWithoutHash_, Object> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
public ModelWithoutHash_ value(int value) {
onMutation();
super.value = value;
return this;
}
public int value() {
return value;
}
public ModelWithoutHash_ value2(int value2) {
onMutation();
super.value2 = value2;
return this;
}
public int value2() {
return value2;
}
public ModelWithoutHash_ value3(String value3) {
onMutation();
super.value3 = value3;
return this;
}
public String value3() {
return value3;
}
@Override
public ModelWithoutHash_ id(long id) {
super.id(id);
return this;
}
@Override
public ModelWithoutHash_ id(@Nullable Number... ids) {
super.id(ids);
return this;
}
@Override
public ModelWithoutHash_ id(long id1, long id2) {
super.id(id1, id2);
return this;
}
@Override
public ModelWithoutHash_ id(@Nullable CharSequence key) {
super.id(key);
return this;
}
@Override
public ModelWithoutHash_ id(@Nullable CharSequence key, @Nullable CharSequence... otherKeys) {
super.id(key, otherKeys);
return this;
}
@Override
public ModelWithoutHash_ id(@Nullable CharSequence key, long id) {
super.id(key, id);
return this;
}
@Override
public ModelWithoutHash_ layout(@LayoutRes int layoutRes) {
super.layout(layoutRes);
return this;
}
@Override
public ModelWithoutHash_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback spanSizeCallback) {
super.spanSizeOverride(spanSizeCallback);
return this;
}
@Override
public ModelWithoutHash_ show() {
super.show();
return this;
}
@Override
public ModelWithoutHash_ show(boolean show) {
super.show(show);
return this;
}
@Override
public ModelWithoutHash_ hide() {
super.hide();
return this;
}
@Override
public ModelWithoutHash_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
super.value = 0;
super.value2 = 0;
super.value3 = null;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof ModelWithoutHash_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
ModelWithoutHash_ that = (ModelWithoutHash_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((value != that.value)) {
return false;
}
if (((value3 == null) != (that.value3 == null))) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + value;
_result = 31 * _result + (value3 != null ? 1 : 0);
return _result;
}
@Override
public String toString() {
return "ModelWithoutHash_{" +
"value=" + value +
", value2=" + value2 +
", value3=" + value3 +
"}" + super.toString();
}
}
| 8,464 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/NullOnRecycleView.java | package com.airbnb.epoxy;
import android.content.Context;
import androidx.annotation.Nullable;
import android.view.View;
import com.airbnb.epoxy.ModelProp.Option;
@ModelView(defaultLayout = 1)
public class NullOnRecycleView extends View {
public NullOnRecycleView(Context context) {
super(context);
}
@ModelProp(options = Option.NullOnRecycle)
public void setTitle(@Nullable CharSequence title) {
}
}
| 8,465 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/ModelWithDataBindingBinding.java | package com.airbnb.epoxy.databinding;
import com.airbnb.epoxy.R;
import com.airbnb.epoxy.BR;
import android.view.View;
public class ModelWithDataBindingBinding extends androidx.databinding.ViewDataBinding {
private static final androidx.databinding.ViewDataBinding.IncludedLayouts sIncludes;
private static final android.util.SparseIntArray sViewsWithIds;
static {
sIncludes = null;
sViewsWithIds = null;
}
// views
public final android.widget.Button button;
// variables
private java.lang.String mStringValue;
// values
// listeners
// Inverse Binding Event Handlers
public ModelWithDataBindingBinding(androidx.databinding.DataBindingComponent bindingComponent, View root) {
super(bindingComponent, root, 0);
final Object[] bindings = mapBindings(bindingComponent, root, 1, sIncludes, sViewsWithIds);
this.button = (android.widget.Button) bindings[0];
this.button.setTag(null);
setRootTag(root);
// listeners
invalidateAll();
}
@Override
public void invalidateAll() {
synchronized(this) {
mDirtyFlags = 0x2L;
}
requestRebind();
}
@Override
public boolean hasPendingBindings() {
synchronized(this) {
if (mDirtyFlags != 0) {
return true;
}
}
return false;
}
public boolean setVariable(int variableId, Object variable) {
switch(variableId) {
case BR.stringValue :
setStringValue((java.lang.String) variable);
return true;
}
return false;
}
public void setStringValue(java.lang.String StringValue) {
this.mStringValue = StringValue;
synchronized(this) {
mDirtyFlags |= 0x1L;
}
notifyPropertyChanged(BR.stringValue);
super.requestRebind();
}
public java.lang.String getStringValue() {
return mStringValue;
}
@Override
protected boolean onFieldChange(int localFieldId, Object object, int fieldId) {
switch (localFieldId) {
}
return false;
}
@Override
protected void executeBindings() {
long dirtyFlags = 0;
synchronized(this) {
dirtyFlags = mDirtyFlags;
mDirtyFlags = 0;
}
java.lang.String stringValue = mStringValue;
if ((dirtyFlags & 0x3L) != 0) {
}
// batch finished
if ((dirtyFlags & 0x3L) != 0) {
// api target 1
androidx.databinding.adapters.TextViewBindingAdapter.setText(this.button, stringValue);
}
}
// Listener Stub Implementations
// callback impls
// dirty flag
private long mDirtyFlags = 0xffffffffffffffffL;
public static ModelWithDataBindingBinding inflate(android.view.LayoutInflater inflater, android.view.ViewGroup root, boolean attachToRoot) {
return inflate(inflater, root, attachToRoot, androidx.databinding.DataBindingUtil.getDefaultComponent());
}
public static ModelWithDataBindingBinding inflate(android.view.LayoutInflater inflater, android.view.ViewGroup root, boolean attachToRoot, androidx.databinding.DataBindingComponent bindingComponent) {
return androidx.databinding.DataBindingUtil.<ModelWithDataBindingBinding>inflate(inflater, com.airbnb.epoxy.R.layout.model_with_data_binding, root, attachToRoot, bindingComponent);
}
public static ModelWithDataBindingBinding inflate(android.view.LayoutInflater inflater) {
return inflate(inflater, androidx.databinding.DataBindingUtil.getDefaultComponent());
}
public static ModelWithDataBindingBinding inflate(android.view.LayoutInflater inflater, androidx.databinding.DataBindingComponent bindingComponent) {
return bind(inflater.inflate(com.airbnb.epoxy.R.layout.model_with_data_binding, null, false), bindingComponent);
}
public static ModelWithDataBindingBinding bind(android.view.View view) {
return bind(view, androidx.databinding.DataBindingUtil.getDefaultComponent());
}
public static ModelWithDataBindingBinding bind(android.view.View view, androidx.databinding.DataBindingComponent bindingComponent) {
if (!"layout/model_with_data_binding_0".equals(view.getTag())) {
throw new RuntimeException("view tag isn't correct on view:" + view.getTag());
}
return new ModelWithDataBindingBinding(bindingComponent, view);
}
/* flag mapping
flag 0 (0x1L): stringValue
flag 1 (0x2L): null
flag mapping end*/
//end
}
| 8,466 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/ModelViewExtendingSuperClass.java | package com.airbnb.epoxy;
import android.content.Context;
import android.view.View;
import com.airbnb.epoxy.ModelView.Size;
@ModelView(autoLayout = Size.MATCH_WIDTH_MATCH_HEIGHT)
public class ModelViewExtendingSuperClass extends View {
public ModelViewExtendingSuperClass(Context context) {
super(context);
}
@ModelProp
void subClassValue(int value) {
}
@ModelProp
void superClassValue(int value) {
// same as super class, expect no duplicate
}
@OnViewRecycled
void onClear() {
}
@OnViewRecycled
void onSubClassCleared() {
}
@AfterPropsSet
void afterProps() {
}
@AfterPropsSet
void onSubclassAfterPropsSet() {
}
} | 8,467 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/PropGroupsViewModel_.java | package com.airbnb.epoxy;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.lang.CharSequence;
import java.lang.IllegalArgumentException;
import java.lang.IllegalStateException;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.util.BitSet;
/**
* Generated file. Do not modify!
*/
public class PropGroupsViewModel_ extends EpoxyModel<PropGroupsView> implements GeneratedModel<PropGroupsView>, PropGroupsViewModelBuilder {
private final BitSet assignedAttributes_epoxyGeneratedModel = new BitSet(14);
private OnModelBoundListener<PropGroupsViewModel_, PropGroupsView> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<PropGroupsViewModel_, PropGroupsView> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<PropGroupsViewModel_, PropGroupsView> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<PropGroupsViewModel_, PropGroupsView> onModelVisibilityChangedListener_epoxyGeneratedModel;
/**
* Bitset index: 0
*/
@Nullable
private CharSequence something_CharSequence = (CharSequence) null;
/**
* Bitset index: 1
*/
private int something_Int = 0;
/**
* Bitset index: 2
*/
@NonNull
private CharSequence somethingElse_CharSequence;
/**
* Bitset index: 3
*/
private int somethingElse_Int = 0;
/**
* Bitset index: 4
*/
private int primitive_Int = 0;
/**
* Bitset index: 5
*/
private long primitive_Long = 0L;
/**
* Bitset index: 6
*/
private int primitiveWithDefault_Int = 0;
/**
* Bitset index: 7
*/
private long primitiveWithDefault_Long = PropGroupsView.DEFAULT_PRIMITIVE;
/**
* Bitset index: 8
*/
private long primitiveAndObjectGroupWithPrimitiveDefault_Long = PropGroupsView.DEFAULT_PRIMITIVE;
/**
* Bitset index: 9
*/
@NonNull
private CharSequence primitiveAndObjectGroupWithPrimitiveDefault_CharSequence;
/**
* Bitset index: 10
*/
private long oneThing_Long = 0L;
/**
* Bitset index: 11
*/
@NonNull
private CharSequence anotherThing_CharSequence;
/**
* Bitset index: 12
*/
@NonNull
private String requiredGroup_String;
/**
* Bitset index: 13
*/
@NonNull
private CharSequence requiredGroup_CharSequence;
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
if (!assignedAttributes_epoxyGeneratedModel.get(12) && !assignedAttributes_epoxyGeneratedModel.get(13)) {
throw new IllegalStateException("A value is required for requiredGroup");
}
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final PropGroupsView object,
final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void bind(final PropGroupsView object) {
super.bind(object);
if (assignedAttributes_epoxyGeneratedModel.get(4)) {
object.setPrimitive(primitive_Int);
}
else if (assignedAttributes_epoxyGeneratedModel.get(5)) {
object.setPrimitive(primitive_Long);
}
else {
object.setPrimitive(primitive_Int);
}
if (assignedAttributes_epoxyGeneratedModel.get(12)) {
object.requiredGroup(requiredGroup_String);
}
else {
object.requiredGroup(requiredGroup_CharSequence);
}
if (assignedAttributes_epoxyGeneratedModel.get(8)) {
object.primitiveAndObjectGroupWithPrimitiveDefault(primitiveAndObjectGroupWithPrimitiveDefault_Long);
}
else if (assignedAttributes_epoxyGeneratedModel.get(9)) {
object.primitiveAndObjectGroupWithPrimitiveDefault(primitiveAndObjectGroupWithPrimitiveDefault_CharSequence);
}
else {
object.primitiveAndObjectGroupWithPrimitiveDefault(primitiveAndObjectGroupWithPrimitiveDefault_Long);
}
if (assignedAttributes_epoxyGeneratedModel.get(10)) {
object.setOneThing(oneThing_Long);
}
else if (assignedAttributes_epoxyGeneratedModel.get(11)) {
object.setAnotherThing(anotherThing_CharSequence);
}
else {
object.setOneThing(oneThing_Long);
}
if (assignedAttributes_epoxyGeneratedModel.get(0)) {
object.setSomething(something_CharSequence);
}
else if (assignedAttributes_epoxyGeneratedModel.get(1)) {
object.setSomething(something_Int);
}
else {
object.setSomething(something_CharSequence);
}
if (assignedAttributes_epoxyGeneratedModel.get(2)) {
object.setSomethingElse(somethingElse_CharSequence);
}
else if (assignedAttributes_epoxyGeneratedModel.get(3)) {
object.setSomethingElse(somethingElse_Int);
}
else {
object.setSomethingElse(somethingElse_Int);
}
if (assignedAttributes_epoxyGeneratedModel.get(6)) {
object.setPrimitiveWithDefault(primitiveWithDefault_Int);
}
else if (assignedAttributes_epoxyGeneratedModel.get(7)) {
object.setPrimitiveWithDefault(primitiveWithDefault_Long);
}
else {
object.setPrimitiveWithDefault(primitiveWithDefault_Long);
}
}
@Override
public void bind(final PropGroupsView object, EpoxyModel previousModel) {
if (!(previousModel instanceof PropGroupsViewModel_)) {
bind(object);
return;
}
PropGroupsViewModel_ that = (PropGroupsViewModel_) previousModel;
super.bind(object);
if (assignedAttributes_epoxyGeneratedModel.get(4)) {
if ((primitive_Int != that.primitive_Int)) {
object.setPrimitive(primitive_Int);
}
}
else if (assignedAttributes_epoxyGeneratedModel.get(5)) {
if ((primitive_Long != that.primitive_Long)) {
object.setPrimitive(primitive_Long);
}
}
// A value was not set so we should use the default value, but we only need to set it if the previous model had a custom value set.
else if (that.assignedAttributes_epoxyGeneratedModel.get(4) || that.assignedAttributes_epoxyGeneratedModel.get(5)) {
object.setPrimitive(primitive_Int);
}
if (assignedAttributes_epoxyGeneratedModel.get(12)) {
if (!that.assignedAttributes_epoxyGeneratedModel.get(12) || (requiredGroup_String != null ? !requiredGroup_String.equals(that.requiredGroup_String) : that.requiredGroup_String != null)) {
object.requiredGroup(requiredGroup_String);
}
}
else if (assignedAttributes_epoxyGeneratedModel.get(13)) {
if (!that.assignedAttributes_epoxyGeneratedModel.get(13) || (requiredGroup_CharSequence != null ? !requiredGroup_CharSequence.equals(that.requiredGroup_CharSequence) : that.requiredGroup_CharSequence != null)) {
object.requiredGroup(requiredGroup_CharSequence);
}
}
if (assignedAttributes_epoxyGeneratedModel.get(8)) {
if ((primitiveAndObjectGroupWithPrimitiveDefault_Long != that.primitiveAndObjectGroupWithPrimitiveDefault_Long)) {
object.primitiveAndObjectGroupWithPrimitiveDefault(primitiveAndObjectGroupWithPrimitiveDefault_Long);
}
}
else if (assignedAttributes_epoxyGeneratedModel.get(9)) {
if (!that.assignedAttributes_epoxyGeneratedModel.get(9) || (primitiveAndObjectGroupWithPrimitiveDefault_CharSequence != null ? !primitiveAndObjectGroupWithPrimitiveDefault_CharSequence.equals(that.primitiveAndObjectGroupWithPrimitiveDefault_CharSequence) : that.primitiveAndObjectGroupWithPrimitiveDefault_CharSequence != null)) {
object.primitiveAndObjectGroupWithPrimitiveDefault(primitiveAndObjectGroupWithPrimitiveDefault_CharSequence);
}
}
// A value was not set so we should use the default value, but we only need to set it if the previous model had a custom value set.
else if (that.assignedAttributes_epoxyGeneratedModel.get(8) || that.assignedAttributes_epoxyGeneratedModel.get(9)) {
object.primitiveAndObjectGroupWithPrimitiveDefault(primitiveAndObjectGroupWithPrimitiveDefault_Long);
}
if (assignedAttributes_epoxyGeneratedModel.get(10)) {
if ((oneThing_Long != that.oneThing_Long)) {
object.setOneThing(oneThing_Long);
}
}
else if (assignedAttributes_epoxyGeneratedModel.get(11)) {
if (!that.assignedAttributes_epoxyGeneratedModel.get(11) || (anotherThing_CharSequence != null ? !anotherThing_CharSequence.equals(that.anotherThing_CharSequence) : that.anotherThing_CharSequence != null)) {
object.setAnotherThing(anotherThing_CharSequence);
}
}
// A value was not set so we should use the default value, but we only need to set it if the previous model had a custom value set.
else if (that.assignedAttributes_epoxyGeneratedModel.get(10) || that.assignedAttributes_epoxyGeneratedModel.get(11)) {
object.setOneThing(oneThing_Long);
}
if (assignedAttributes_epoxyGeneratedModel.get(0)) {
if (!that.assignedAttributes_epoxyGeneratedModel.get(0) || (something_CharSequence != null ? !something_CharSequence.equals(that.something_CharSequence) : that.something_CharSequence != null)) {
object.setSomething(something_CharSequence);
}
}
else if (assignedAttributes_epoxyGeneratedModel.get(1)) {
if ((something_Int != that.something_Int)) {
object.setSomething(something_Int);
}
}
// A value was not set so we should use the default value, but we only need to set it if the previous model had a custom value set.
else if (that.assignedAttributes_epoxyGeneratedModel.get(0) || that.assignedAttributes_epoxyGeneratedModel.get(1)) {
object.setSomething(something_CharSequence);
}
if (assignedAttributes_epoxyGeneratedModel.get(2)) {
if (!that.assignedAttributes_epoxyGeneratedModel.get(2) || (somethingElse_CharSequence != null ? !somethingElse_CharSequence.equals(that.somethingElse_CharSequence) : that.somethingElse_CharSequence != null)) {
object.setSomethingElse(somethingElse_CharSequence);
}
}
else if (assignedAttributes_epoxyGeneratedModel.get(3)) {
if ((somethingElse_Int != that.somethingElse_Int)) {
object.setSomethingElse(somethingElse_Int);
}
}
// A value was not set so we should use the default value, but we only need to set it if the previous model had a custom value set.
else if (that.assignedAttributes_epoxyGeneratedModel.get(2) || that.assignedAttributes_epoxyGeneratedModel.get(3)) {
object.setSomethingElse(somethingElse_Int);
}
if (assignedAttributes_epoxyGeneratedModel.get(6)) {
if ((primitiveWithDefault_Int != that.primitiveWithDefault_Int)) {
object.setPrimitiveWithDefault(primitiveWithDefault_Int);
}
}
else if (assignedAttributes_epoxyGeneratedModel.get(7)) {
if ((primitiveWithDefault_Long != that.primitiveWithDefault_Long)) {
object.setPrimitiveWithDefault(primitiveWithDefault_Long);
}
}
// A value was not set so we should use the default value, but we only need to set it if the previous model had a custom value set.
else if (that.assignedAttributes_epoxyGeneratedModel.get(6) || that.assignedAttributes_epoxyGeneratedModel.get(7)) {
object.setPrimitiveWithDefault(primitiveWithDefault_Long);
}
}
@Override
public void handlePostBind(final PropGroupsView object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public PropGroupsViewModel_ onBind(
OnModelBoundListener<PropGroupsViewModel_, PropGroupsView> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(PropGroupsView object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public PropGroupsViewModel_ onUnbind(
OnModelUnboundListener<PropGroupsViewModel_, PropGroupsView> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState, final PropGroupsView object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public PropGroupsViewModel_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<PropGroupsViewModel_, PropGroupsView> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final PropGroupsView object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public PropGroupsViewModel_ onVisibilityChanged(
OnModelVisibilityChangedListener<PropGroupsViewModel_, PropGroupsView> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
/**
* <i>Optional</i>: Default value is (CharSequence) null
*
* @see PropGroupsView#setSomething(CharSequence)
*/
public PropGroupsViewModel_ something(@Nullable CharSequence something) {
assignedAttributes_epoxyGeneratedModel.set(0);
assignedAttributes_epoxyGeneratedModel.clear(1);
this.something_Int = 0;
onMutation();
this.something_CharSequence = something;
return this;
}
@Nullable
public CharSequence somethingCharSequence() {
return something_CharSequence;
}
/**
* <i>Optional</i>: Default value is 0
*
* @see PropGroupsView#setSomething(int)
*/
public PropGroupsViewModel_ something(int something) {
assignedAttributes_epoxyGeneratedModel.set(1);
assignedAttributes_epoxyGeneratedModel.clear(0);
this.something_CharSequence = (CharSequence) null;
onMutation();
this.something_Int = something;
return this;
}
public int somethingInt() {
return something_Int;
}
/**
* <i>Required.</i>
*
* @see PropGroupsView#setSomethingElse(CharSequence)
*/
public PropGroupsViewModel_ somethingElse(@NonNull CharSequence somethingElse) {
if (somethingElse == null) {
throw new IllegalArgumentException("somethingElse cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(2);
assignedAttributes_epoxyGeneratedModel.clear(3);
this.somethingElse_Int = 0;
onMutation();
this.somethingElse_CharSequence = somethingElse;
return this;
}
@NonNull
public CharSequence somethingElseCharSequence() {
return somethingElse_CharSequence;
}
/**
* <i>Optional</i>: Default value is 0
*
* @see PropGroupsView#setSomethingElse(int)
*/
public PropGroupsViewModel_ somethingElse(int somethingElse) {
assignedAttributes_epoxyGeneratedModel.set(3);
assignedAttributes_epoxyGeneratedModel.clear(2);
this.somethingElse_CharSequence = null;
onMutation();
this.somethingElse_Int = somethingElse;
return this;
}
public int somethingElseInt() {
return somethingElse_Int;
}
/**
* <i>Optional</i>: Default value is 0
*
* @see PropGroupsView#setPrimitive(int)
*/
public PropGroupsViewModel_ primitive(int primitive) {
assignedAttributes_epoxyGeneratedModel.set(4);
assignedAttributes_epoxyGeneratedModel.clear(5);
this.primitive_Long = 0L;
onMutation();
this.primitive_Int = primitive;
return this;
}
public int primitiveInt() {
return primitive_Int;
}
/**
* <i>Optional</i>: Default value is 0L
*
* @see PropGroupsView#setPrimitive(long)
*/
public PropGroupsViewModel_ primitive(long primitive) {
assignedAttributes_epoxyGeneratedModel.set(5);
assignedAttributes_epoxyGeneratedModel.clear(4);
this.primitive_Int = 0;
onMutation();
this.primitive_Long = primitive;
return this;
}
public long primitiveLong() {
return primitive_Long;
}
/**
* <i>Optional</i>: Default value is 0
*
* @see PropGroupsView#setPrimitiveWithDefault(int)
*/
public PropGroupsViewModel_ primitiveWithDefault(int primitiveWithDefault) {
assignedAttributes_epoxyGeneratedModel.set(6);
assignedAttributes_epoxyGeneratedModel.clear(7);
this.primitiveWithDefault_Long = PropGroupsView.DEFAULT_PRIMITIVE;
onMutation();
this.primitiveWithDefault_Int = primitiveWithDefault;
return this;
}
public int primitiveWithDefaultInt() {
return primitiveWithDefault_Int;
}
/**
* <i>Optional</i>: Default value is <b>{@value PropGroupsView#DEFAULT_PRIMITIVE}</b>
*
* @see PropGroupsView#setPrimitiveWithDefault(long)
*/
public PropGroupsViewModel_ primitiveWithDefault(long primitiveWithDefault) {
assignedAttributes_epoxyGeneratedModel.set(7);
assignedAttributes_epoxyGeneratedModel.clear(6);
this.primitiveWithDefault_Int = 0;
onMutation();
this.primitiveWithDefault_Long = primitiveWithDefault;
return this;
}
public long primitiveWithDefaultLong() {
return primitiveWithDefault_Long;
}
/**
* <i>Optional</i>: Default value is <b>{@value PropGroupsView#DEFAULT_PRIMITIVE}</b>
*
* @see PropGroupsView#primitiveAndObjectGroupWithPrimitiveDefault(long)
*/
public PropGroupsViewModel_ primitiveAndObjectGroupWithPrimitiveDefault(
long primitiveAndObjectGroupWithPrimitiveDefault) {
assignedAttributes_epoxyGeneratedModel.set(8);
assignedAttributes_epoxyGeneratedModel.clear(9);
this.primitiveAndObjectGroupWithPrimitiveDefault_CharSequence = null;
onMutation();
this.primitiveAndObjectGroupWithPrimitiveDefault_Long = primitiveAndObjectGroupWithPrimitiveDefault;
return this;
}
public long primitiveAndObjectGroupWithPrimitiveDefaultLong() {
return primitiveAndObjectGroupWithPrimitiveDefault_Long;
}
/**
* <i>Required.</i>
*
* @see PropGroupsView#primitiveAndObjectGroupWithPrimitiveDefault(CharSequence)
*/
public PropGroupsViewModel_ primitiveAndObjectGroupWithPrimitiveDefault(
@NonNull CharSequence primitiveAndObjectGroupWithPrimitiveDefault) {
if (primitiveAndObjectGroupWithPrimitiveDefault == null) {
throw new IllegalArgumentException("primitiveAndObjectGroupWithPrimitiveDefault cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(9);
assignedAttributes_epoxyGeneratedModel.clear(8);
this.primitiveAndObjectGroupWithPrimitiveDefault_Long = PropGroupsView.DEFAULT_PRIMITIVE;
onMutation();
this.primitiveAndObjectGroupWithPrimitiveDefault_CharSequence = primitiveAndObjectGroupWithPrimitiveDefault;
return this;
}
@NonNull
public CharSequence primitiveAndObjectGroupWithPrimitiveDefaultCharSequence() {
return primitiveAndObjectGroupWithPrimitiveDefault_CharSequence;
}
/**
* <i>Optional</i>: Default value is 0L
*
* @see PropGroupsView#setOneThing(long)
*/
public PropGroupsViewModel_ oneThing(long oneThing) {
assignedAttributes_epoxyGeneratedModel.set(10);
assignedAttributes_epoxyGeneratedModel.clear(11);
this.anotherThing_CharSequence = null;
onMutation();
this.oneThing_Long = oneThing;
return this;
}
public long oneThingLong() {
return oneThing_Long;
}
/**
* <i>Required.</i>
*
* @see PropGroupsView#setAnotherThing(CharSequence)
*/
public PropGroupsViewModel_ anotherThing(@NonNull CharSequence anotherThing) {
if (anotherThing == null) {
throw new IllegalArgumentException("anotherThing cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(11);
assignedAttributes_epoxyGeneratedModel.clear(10);
this.oneThing_Long = 0L;
onMutation();
this.anotherThing_CharSequence = anotherThing;
return this;
}
@NonNull
public CharSequence anotherThingCharSequence() {
return anotherThing_CharSequence;
}
/**
* <i>Required.</i>
*
* @see PropGroupsView#requiredGroup(String)
*/
public PropGroupsViewModel_ requiredGroup(@NonNull String requiredGroup) {
if (requiredGroup == null) {
throw new IllegalArgumentException("requiredGroup cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(12);
assignedAttributes_epoxyGeneratedModel.clear(13);
this.requiredGroup_CharSequence = null;
onMutation();
this.requiredGroup_String = requiredGroup;
return this;
}
@NonNull
public String requiredGroupString() {
return requiredGroup_String;
}
/**
* <i>Required.</i>
*
* @see PropGroupsView#requiredGroup(CharSequence)
*/
public PropGroupsViewModel_ requiredGroup(@NonNull CharSequence requiredGroup) {
if (requiredGroup == null) {
throw new IllegalArgumentException("requiredGroup cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(13);
assignedAttributes_epoxyGeneratedModel.clear(12);
this.requiredGroup_String = null;
onMutation();
this.requiredGroup_CharSequence = requiredGroup;
return this;
}
@NonNull
public CharSequence requiredGroupCharSequence() {
return requiredGroup_CharSequence;
}
@Override
public PropGroupsViewModel_ id(long id) {
super.id(id);
return this;
}
@Override
public PropGroupsViewModel_ id(@Nullable Number... ids) {
super.id(ids);
return this;
}
@Override
public PropGroupsViewModel_ id(long id1, long id2) {
super.id(id1, id2);
return this;
}
@Override
public PropGroupsViewModel_ id(@Nullable CharSequence key) {
super.id(key);
return this;
}
@Override
public PropGroupsViewModel_ id(@Nullable CharSequence key, @Nullable CharSequence... otherKeys) {
super.id(key, otherKeys);
return this;
}
@Override
public PropGroupsViewModel_ id(@Nullable CharSequence key, long id) {
super.id(key, id);
return this;
}
@Override
public PropGroupsViewModel_ layout(@LayoutRes int layoutRes) {
super.layout(layoutRes);
return this;
}
@Override
public PropGroupsViewModel_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback spanSizeCallback) {
super.spanSizeOverride(spanSizeCallback);
return this;
}
@Override
public PropGroupsViewModel_ show() {
super.show();
return this;
}
@Override
public PropGroupsViewModel_ show(boolean show) {
super.show(show);
return this;
}
@Override
public PropGroupsViewModel_ hide() {
super.hide();
return this;
}
@Override
@LayoutRes
protected int getDefaultLayout() {
return 1;
}
@Override
public PropGroupsViewModel_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
assignedAttributes_epoxyGeneratedModel.clear();
this.something_CharSequence = (CharSequence) null;
this.something_Int = 0;
this.somethingElse_CharSequence = null;
this.somethingElse_Int = 0;
this.primitive_Int = 0;
this.primitive_Long = 0L;
this.primitiveWithDefault_Int = 0;
this.primitiveWithDefault_Long = PropGroupsView.DEFAULT_PRIMITIVE;
this.primitiveAndObjectGroupWithPrimitiveDefault_Long = PropGroupsView.DEFAULT_PRIMITIVE;
this.primitiveAndObjectGroupWithPrimitiveDefault_CharSequence = null;
this.oneThing_Long = 0L;
this.anotherThing_CharSequence = null;
this.requiredGroup_String = null;
this.requiredGroup_CharSequence = null;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof PropGroupsViewModel_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
PropGroupsViewModel_ that = (PropGroupsViewModel_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((something_CharSequence != null ? !something_CharSequence.equals(that.something_CharSequence) : that.something_CharSequence != null)) {
return false;
}
if ((something_Int != that.something_Int)) {
return false;
}
if ((somethingElse_CharSequence != null ? !somethingElse_CharSequence.equals(that.somethingElse_CharSequence) : that.somethingElse_CharSequence != null)) {
return false;
}
if ((somethingElse_Int != that.somethingElse_Int)) {
return false;
}
if ((primitive_Int != that.primitive_Int)) {
return false;
}
if ((primitive_Long != that.primitive_Long)) {
return false;
}
if ((primitiveWithDefault_Int != that.primitiveWithDefault_Int)) {
return false;
}
if ((primitiveWithDefault_Long != that.primitiveWithDefault_Long)) {
return false;
}
if ((primitiveAndObjectGroupWithPrimitiveDefault_Long != that.primitiveAndObjectGroupWithPrimitiveDefault_Long)) {
return false;
}
if ((primitiveAndObjectGroupWithPrimitiveDefault_CharSequence != null ? !primitiveAndObjectGroupWithPrimitiveDefault_CharSequence.equals(that.primitiveAndObjectGroupWithPrimitiveDefault_CharSequence) : that.primitiveAndObjectGroupWithPrimitiveDefault_CharSequence != null)) {
return false;
}
if ((oneThing_Long != that.oneThing_Long)) {
return false;
}
if ((anotherThing_CharSequence != null ? !anotherThing_CharSequence.equals(that.anotherThing_CharSequence) : that.anotherThing_CharSequence != null)) {
return false;
}
if ((requiredGroup_String != null ? !requiredGroup_String.equals(that.requiredGroup_String) : that.requiredGroup_String != null)) {
return false;
}
if ((requiredGroup_CharSequence != null ? !requiredGroup_CharSequence.equals(that.requiredGroup_CharSequence) : that.requiredGroup_CharSequence != null)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (something_CharSequence != null ? something_CharSequence.hashCode() : 0);
_result = 31 * _result + something_Int;
_result = 31 * _result + (somethingElse_CharSequence != null ? somethingElse_CharSequence.hashCode() : 0);
_result = 31 * _result + somethingElse_Int;
_result = 31 * _result + primitive_Int;
_result = 31 * _result + (int) (primitive_Long ^ (primitive_Long >>> 32));
_result = 31 * _result + primitiveWithDefault_Int;
_result = 31 * _result + (int) (primitiveWithDefault_Long ^ (primitiveWithDefault_Long >>> 32));
_result = 31 * _result + (int) (primitiveAndObjectGroupWithPrimitiveDefault_Long ^ (primitiveAndObjectGroupWithPrimitiveDefault_Long >>> 32));
_result = 31 * _result + (primitiveAndObjectGroupWithPrimitiveDefault_CharSequence != null ? primitiveAndObjectGroupWithPrimitiveDefault_CharSequence.hashCode() : 0);
_result = 31 * _result + (int) (oneThing_Long ^ (oneThing_Long >>> 32));
_result = 31 * _result + (anotherThing_CharSequence != null ? anotherThing_CharSequence.hashCode() : 0);
_result = 31 * _result + (requiredGroup_String != null ? requiredGroup_String.hashCode() : 0);
_result = 31 * _result + (requiredGroup_CharSequence != null ? requiredGroup_CharSequence.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "PropGroupsViewModel_{" +
"something_CharSequence=" + something_CharSequence +
", something_Int=" + something_Int +
", somethingElse_CharSequence=" + somethingElse_CharSequence +
", somethingElse_Int=" + somethingElse_Int +
", primitive_Int=" + primitive_Int +
", primitive_Long=" + primitive_Long +
", primitiveWithDefault_Int=" + primitiveWithDefault_Int +
", primitiveWithDefault_Long=" + primitiveWithDefault_Long +
", primitiveAndObjectGroupWithPrimitiveDefault_Long=" + primitiveAndObjectGroupWithPrimitiveDefault_Long +
", primitiveAndObjectGroupWithPrimitiveDefault_CharSequence=" + primitiveAndObjectGroupWithPrimitiveDefault_CharSequence +
", oneThing_Long=" + oneThing_Long +
", anotherThing_CharSequence=" + anotherThing_CharSequence +
", requiredGroup_String=" + requiredGroup_String +
", requiredGroup_CharSequence=" + requiredGroup_CharSequence +
"}" + super.toString();
}
@Override
public int getSpanSize(int totalSpanCount, int position, int itemCount) {
return totalSpanCount;
}
}
| 8,468 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/TestFieldPropStringOverloadsIfNotCharSequenceView.java | package com.airbnb.epoxy;
import android.content.Context;
import android.view.View;
import com.airbnb.epoxy.AfterPropsSet;
import com.airbnb.epoxy.ModelProp;
import com.airbnb.epoxy.ModelProp.Option;
import com.airbnb.epoxy.ModelView;
@ModelView(autoLayout = ModelView.Size.WRAP_WIDTH_WRAP_HEIGHT)
public class TestFieldPropStringOverloadsIfNotCharSequenceView extends View {
@ModelProp(options = Option.GenerateStringOverloads) OnClickListener value;
public TestFieldPropStringOverloadsIfNotCharSequenceView(Context context) {
super(context);
}
@AfterPropsSet
public void call() {
}
}
| 8,469 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/ModelWithAllFieldTypes.java | package com.airbnb.epoxy;
import java.util.List;
public class ModelWithAllFieldTypes extends EpoxyModel<Object> {
@EpoxyAttribute int valueInt;
@EpoxyAttribute Integer valueInteger;
@EpoxyAttribute short valueShort;
@EpoxyAttribute Short valueShortWrapper;
@EpoxyAttribute char valueChar;
@EpoxyAttribute Character valueCharacter;
@EpoxyAttribute byte valuebByte;
@EpoxyAttribute Byte valueByteWrapper;
@EpoxyAttribute long valueLong;
@EpoxyAttribute Long valueLongWrapper;
@EpoxyAttribute double valueDouble;
@EpoxyAttribute Double valueDoubleWrapper;
@EpoxyAttribute float valueFloat;
@EpoxyAttribute Float valueFloatWrapper;
@EpoxyAttribute boolean valueBoolean;
@EpoxyAttribute Boolean valueBooleanWrapper;
@EpoxyAttribute int[] valueIntArray;
@EpoxyAttribute Object[] valueObjectArray;
@EpoxyAttribute String valueString;
@EpoxyAttribute Object valueObject;
@EpoxyAttribute List<String> valueList;
@Override
protected int getDefaultLayout() {
return 0;
}
} | 8,470 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/ModelWithCheckedChangeListener_.java | package com.airbnb.epoxy;
import android.widget.CompoundButton;
import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;
import java.lang.CharSequence;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
/**
* Generated file. Do not modify!
*/
public class ModelWithCheckedChangeListener_ extends ModelWithCheckedChangeListener implements GeneratedModel<Object>, ModelWithCheckedChangeListenerBuilder {
private OnModelBoundListener<ModelWithCheckedChangeListener_, Object> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<ModelWithCheckedChangeListener_, Object> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<ModelWithCheckedChangeListener_, Object> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<ModelWithCheckedChangeListener_, Object> onModelVisibilityChangedListener_epoxyGeneratedModel;
public ModelWithCheckedChangeListener_() {
super();
}
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final Object object, final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void handlePostBind(final Object object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ModelWithCheckedChangeListener_ onBind(
OnModelBoundListener<ModelWithCheckedChangeListener_, Object> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(Object object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ModelWithCheckedChangeListener_ onUnbind(
OnModelUnboundListener<ModelWithCheckedChangeListener_, Object> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState, final Object object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ModelWithCheckedChangeListener_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<ModelWithCheckedChangeListener_, Object> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final Object object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ModelWithCheckedChangeListener_ onVisibilityChanged(
OnModelVisibilityChangedListener<ModelWithCheckedChangeListener_, Object> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
/**
* Set a checked change listener that will provide the parent view, model, value, and adapter position of the checked view. This will clear the normal CompoundButton.OnCheckedChangeListener if one has been set
*/
public ModelWithCheckedChangeListener_ checkedListener(
final OnModelCheckedChangeListener<ModelWithCheckedChangeListener_, Object> checkedListener) {
onMutation();
if (checkedListener == null) {
super.checkedListener = null;
}
else {
super.checkedListener = new WrappedEpoxyModelCheckedChangeListener(checkedListener);
}
return this;
}
public ModelWithCheckedChangeListener_ checkedListener(
CompoundButton.OnCheckedChangeListener checkedListener) {
onMutation();
super.checkedListener = checkedListener;
return this;
}
public CompoundButton.OnCheckedChangeListener checkedListener() {
return checkedListener;
}
@Override
public ModelWithCheckedChangeListener_ id(long id) {
super.id(id);
return this;
}
@Override
public ModelWithCheckedChangeListener_ id(@Nullable Number... ids) {
super.id(ids);
return this;
}
@Override
public ModelWithCheckedChangeListener_ id(long id1, long id2) {
super.id(id1, id2);
return this;
}
@Override
public ModelWithCheckedChangeListener_ id(@Nullable CharSequence key) {
super.id(key);
return this;
}
@Override
public ModelWithCheckedChangeListener_ id(@Nullable CharSequence key,
@Nullable CharSequence... otherKeys) {
super.id(key, otherKeys);
return this;
}
@Override
public ModelWithCheckedChangeListener_ id(@Nullable CharSequence key, long id) {
super.id(key, id);
return this;
}
@Override
public ModelWithCheckedChangeListener_ layout(@LayoutRes int layoutRes) {
super.layout(layoutRes);
return this;
}
@Override
public ModelWithCheckedChangeListener_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback spanSizeCallback) {
super.spanSizeOverride(spanSizeCallback);
return this;
}
@Override
public ModelWithCheckedChangeListener_ show() {
super.show();
return this;
}
@Override
public ModelWithCheckedChangeListener_ show(boolean show) {
super.show(show);
return this;
}
@Override
public ModelWithCheckedChangeListener_ hide() {
super.hide();
return this;
}
@Override
public ModelWithCheckedChangeListener_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
super.checkedListener = null;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof ModelWithCheckedChangeListener_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
ModelWithCheckedChangeListener_ that = (ModelWithCheckedChangeListener_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((checkedListener == null) != (that.checkedListener == null))) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (checkedListener != null ? 1 : 0);
return _result;
}
@Override
public String toString() {
return "ModelWithCheckedChangeListener_{" +
"checkedListener=" + checkedListener +
"}" + super.toString();
}
}
| 8,471 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/OnVisibilityStateChangedViewModel_.java | package com.airbnb.epoxy;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.lang.CharSequence;
import java.lang.IllegalArgumentException;
import java.lang.IllegalStateException;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.util.BitSet;
/**
* Generated file. Do not modify!
*/
public class OnVisibilityStateChangedViewModel_ extends EpoxyModel<OnVisibilityStateChangedView> implements GeneratedModel<OnVisibilityStateChangedView>, OnVisibilityStateChangedViewModelBuilder {
private final BitSet assignedAttributes_epoxyGeneratedModel = new BitSet(1);
private OnModelBoundListener<OnVisibilityStateChangedViewModel_, OnVisibilityStateChangedView> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<OnVisibilityStateChangedViewModel_, OnVisibilityStateChangedView> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<OnVisibilityStateChangedViewModel_, OnVisibilityStateChangedView> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<OnVisibilityStateChangedViewModel_, OnVisibilityStateChangedView> onModelVisibilityChangedListener_epoxyGeneratedModel;
/**
* Bitset index: 0
*/
@NonNull
private CharSequence title_CharSequence;
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
if (!assignedAttributes_epoxyGeneratedModel.get(0)) {
throw new IllegalStateException("A value is required for setTitle");
}
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final OnVisibilityStateChangedView object,
final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void bind(final OnVisibilityStateChangedView object) {
super.bind(object);
object.setTitle(title_CharSequence);
}
@Override
public void bind(final OnVisibilityStateChangedView object, EpoxyModel previousModel) {
if (!(previousModel instanceof OnVisibilityStateChangedViewModel_)) {
bind(object);
return;
}
OnVisibilityStateChangedViewModel_ that = (OnVisibilityStateChangedViewModel_) previousModel;
super.bind(object);
if ((title_CharSequence != null ? !title_CharSequence.equals(that.title_CharSequence) : that.title_CharSequence != null)) {
object.setTitle(title_CharSequence);
}
}
@Override
public void handlePostBind(final OnVisibilityStateChangedView object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public OnVisibilityStateChangedViewModel_ onBind(
OnModelBoundListener<OnVisibilityStateChangedViewModel_, OnVisibilityStateChangedView> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(OnVisibilityStateChangedView object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public OnVisibilityStateChangedViewModel_ onUnbind(
OnModelUnboundListener<OnVisibilityStateChangedViewModel_, OnVisibilityStateChangedView> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState,
final OnVisibilityStateChangedView object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
object.onVisibilityStateChanged1(visibilityState);
object.onVisibilityStateChanged2(visibilityState);
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public OnVisibilityStateChangedViewModel_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<OnVisibilityStateChangedViewModel_, OnVisibilityStateChangedView> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final OnVisibilityStateChangedView object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public OnVisibilityStateChangedViewModel_ onVisibilityChanged(
OnModelVisibilityChangedListener<OnVisibilityStateChangedViewModel_, OnVisibilityStateChangedView> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
/**
* <i>Required.</i>
*
* @see OnVisibilityStateChangedView#setTitle(CharSequence)
*/
public OnVisibilityStateChangedViewModel_ title(@NonNull CharSequence title) {
if (title == null) {
throw new IllegalArgumentException("title cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(0);
onMutation();
this.title_CharSequence = title;
return this;
}
@NonNull
public CharSequence title() {
return title_CharSequence;
}
@Override
public OnVisibilityStateChangedViewModel_ id(long id) {
super.id(id);
return this;
}
@Override
public OnVisibilityStateChangedViewModel_ id(@Nullable Number... ids) {
super.id(ids);
return this;
}
@Override
public OnVisibilityStateChangedViewModel_ id(long id1, long id2) {
super.id(id1, id2);
return this;
}
@Override
public OnVisibilityStateChangedViewModel_ id(@Nullable CharSequence key) {
super.id(key);
return this;
}
@Override
public OnVisibilityStateChangedViewModel_ id(@Nullable CharSequence key,
@Nullable CharSequence... otherKeys) {
super.id(key, otherKeys);
return this;
}
@Override
public OnVisibilityStateChangedViewModel_ id(@Nullable CharSequence key, long id) {
super.id(key, id);
return this;
}
@Override
public OnVisibilityStateChangedViewModel_ layout(@LayoutRes int layoutRes) {
super.layout(layoutRes);
return this;
}
@Override
public OnVisibilityStateChangedViewModel_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback spanSizeCallback) {
super.spanSizeOverride(spanSizeCallback);
return this;
}
@Override
public OnVisibilityStateChangedViewModel_ show() {
super.show();
return this;
}
@Override
public OnVisibilityStateChangedViewModel_ show(boolean show) {
super.show(show);
return this;
}
@Override
public OnVisibilityStateChangedViewModel_ hide() {
super.hide();
return this;
}
@Override
@LayoutRes
protected int getDefaultLayout() {
return 1;
}
@Override
public OnVisibilityStateChangedViewModel_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
assignedAttributes_epoxyGeneratedModel.clear();
this.title_CharSequence = null;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof OnVisibilityStateChangedViewModel_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
OnVisibilityStateChangedViewModel_ that = (OnVisibilityStateChangedViewModel_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((title_CharSequence != null ? !title_CharSequence.equals(that.title_CharSequence) : that.title_CharSequence != null)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (title_CharSequence != null ? title_CharSequence.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "OnVisibilityStateChangedViewModel_{" +
"title_CharSequence=" + title_CharSequence +
"}" + super.toString();
}
@Override
public int getSpanSize(int totalSpanCount, int position, int itemCount) {
return totalSpanCount;
}
}
| 8,472 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/ModelDoNotHash_.java | package com.airbnb.epoxy;
import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;
import java.lang.CharSequence;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
/**
* Generated file. Do not modify!
*/
public class ModelDoNotHash_ extends ModelDoNotHash implements GeneratedModel<Object>, ModelDoNotHashBuilder {
private OnModelBoundListener<ModelDoNotHash_, Object> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<ModelDoNotHash_, Object> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<ModelDoNotHash_, Object> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<ModelDoNotHash_, Object> onModelVisibilityChangedListener_epoxyGeneratedModel;
public ModelDoNotHash_() {
super();
}
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final Object object, final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void handlePostBind(final Object object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ModelDoNotHash_ onBind(OnModelBoundListener<ModelDoNotHash_, Object> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(Object object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ModelDoNotHash_ onUnbind(OnModelUnboundListener<ModelDoNotHash_, Object> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState, final Object object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ModelDoNotHash_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<ModelDoNotHash_, Object> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final Object object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ModelDoNotHash_ onVisibilityChanged(
OnModelVisibilityChangedListener<ModelDoNotHash_, Object> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
public ModelDoNotHash_ value(int value) {
onMutation();
super.value = value;
return this;
}
public int value() {
return value;
}
public ModelDoNotHash_ value2(int value2) {
onMutation();
super.value2 = value2;
return this;
}
public int value2() {
return value2;
}
public ModelDoNotHash_ value3(String value3) {
onMutation();
super.value3 = value3;
return this;
}
public String value3() {
return value3;
}
@Override
public ModelDoNotHash_ id(long id) {
super.id(id);
return this;
}
@Override
public ModelDoNotHash_ id(@Nullable Number... ids) {
super.id(ids);
return this;
}
@Override
public ModelDoNotHash_ id(long id1, long id2) {
super.id(id1, id2);
return this;
}
@Override
public ModelDoNotHash_ id(@Nullable CharSequence key) {
super.id(key);
return this;
}
@Override
public ModelDoNotHash_ id(@Nullable CharSequence key, @Nullable CharSequence... otherKeys) {
super.id(key, otherKeys);
return this;
}
@Override
public ModelDoNotHash_ id(@Nullable CharSequence key, long id) {
super.id(key, id);
return this;
}
@Override
public ModelDoNotHash_ layout(@LayoutRes int layoutRes) {
super.layout(layoutRes);
return this;
}
@Override
public ModelDoNotHash_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback spanSizeCallback) {
super.spanSizeOverride(spanSizeCallback);
return this;
}
@Override
public ModelDoNotHash_ show() {
super.show();
return this;
}
@Override
public ModelDoNotHash_ show(boolean show) {
super.show(show);
return this;
}
@Override
public ModelDoNotHash_ hide() {
super.hide();
return this;
}
@Override
public ModelDoNotHash_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
super.value = 0;
super.value2 = 0;
super.value3 = null;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof ModelDoNotHash_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
ModelDoNotHash_ that = (ModelDoNotHash_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((value != that.value)) {
return false;
}
if (((value3 == null) != (that.value3 == null))) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + value;
_result = 31 * _result + (value3 != null ? 1 : 0);
return _result;
}
@Override
public String toString() {
return "ModelDoNotHash_{" +
"value=" + value +
", value2=" + value2 +
", value3=" + value3 +
"}" + super.toString();
}
}
| 8,473 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/TestFieldPropChildViewModel_.java | package com.airbnb.epoxy;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.PluralsRes;
import androidx.annotation.StringRes;
import java.lang.CharSequence;
import java.lang.IllegalArgumentException;
import java.lang.IllegalStateException;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.lang.UnsupportedOperationException;
import java.util.BitSet;
import javax.annotation.Nullable;
/**
* Generated file. Do not modify!
*/
public class TestFieldPropChildViewModel_ extends EpoxyModel<TestFieldPropChildView> implements GeneratedModel<TestFieldPropChildView>, TestFieldPropChildViewModelBuilder {
private final BitSet assignedAttributes_epoxyGeneratedModel = new BitSet(2);
private OnModelBoundListener<TestFieldPropChildViewModel_, TestFieldPropChildView> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<TestFieldPropChildViewModel_, TestFieldPropChildView> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<TestFieldPropChildViewModel_, TestFieldPropChildView> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<TestFieldPropChildViewModel_, TestFieldPropChildView> onModelVisibilityChangedListener_epoxyGeneratedModel;
/**
* Bitset index: 0
*/
private StringAttributeData textValue_StringAttributeData = new StringAttributeData();
@Nullable
private View.OnClickListener value_OnClickListener = (View.OnClickListener) null;
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
if (!assignedAttributes_epoxyGeneratedModel.get(0)) {
throw new IllegalStateException("A value is required for textValue");
}
}
@Override
protected int getViewType() {
return 0;
}
@Override
public TestFieldPropChildView buildView(ViewGroup parent) {
TestFieldPropChildView v = new TestFieldPropChildView(parent.getContext());
v.setLayoutParams(new ViewGroup.MarginLayoutParams(ViewGroup.MarginLayoutParams.WRAP_CONTENT, ViewGroup.MarginLayoutParams.WRAP_CONTENT));
return v;
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final TestFieldPropChildView object,
final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void bind(final TestFieldPropChildView object) {
super.bind(object);
object.textValue = textValue_StringAttributeData.toString(object.getContext());
object.value = value_OnClickListener;
}
@Override
public void bind(final TestFieldPropChildView object, EpoxyModel previousModel) {
if (!(previousModel instanceof TestFieldPropChildViewModel_)) {
bind(object);
return;
}
TestFieldPropChildViewModel_ that = (TestFieldPropChildViewModel_) previousModel;
super.bind(object);
if ((textValue_StringAttributeData != null ? !textValue_StringAttributeData.equals(that.textValue_StringAttributeData) : that.textValue_StringAttributeData != null)) {
object.textValue = textValue_StringAttributeData.toString(object.getContext());
}
if ((value_OnClickListener != null ? !value_OnClickListener.equals(that.value_OnClickListener) : that.value_OnClickListener != null)) {
object.value = value_OnClickListener;
}
}
@Override
public void handlePostBind(final TestFieldPropChildView object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
object.call();
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public TestFieldPropChildViewModel_ onBind(
OnModelBoundListener<TestFieldPropChildViewModel_, TestFieldPropChildView> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(TestFieldPropChildView object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
object.value = (View.OnClickListener) null;
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public TestFieldPropChildViewModel_ onUnbind(
OnModelUnboundListener<TestFieldPropChildViewModel_, TestFieldPropChildView> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState, final TestFieldPropChildView object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public TestFieldPropChildViewModel_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<TestFieldPropChildViewModel_, TestFieldPropChildView> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final TestFieldPropChildView object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public TestFieldPropChildViewModel_ onVisibilityChanged(
OnModelVisibilityChangedListener<TestFieldPropChildViewModel_, TestFieldPropChildView> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
public CharSequence getTextValue(Context context) {
return textValue_StringAttributeData.toString(context);
}
/**
* <i>Required.</i>
*
* @see TestFieldPropChildView#textValue
*/
public TestFieldPropChildViewModel_ textValue(@NonNull CharSequence textValue) {
onMutation();
assignedAttributes_epoxyGeneratedModel.set(0);
if (textValue == null) {
throw new IllegalArgumentException("textValue cannot be null");
}
textValue_StringAttributeData.setValue(textValue);
return this;
}
/**
* Throws if a value <= 0 is set.
* <p>
* <i>Required.</i>
*
* @see TestFieldPropChildView#textValue
*/
public TestFieldPropChildViewModel_ textValue(@StringRes int stringRes) {
onMutation();
assignedAttributes_epoxyGeneratedModel.set(0);
textValue_StringAttributeData.setValue(stringRes);
return this;
}
/**
* Throws if a value <= 0 is set.
* <p>
* <i>Required.</i>
*
* @see TestFieldPropChildView#textValue
*/
public TestFieldPropChildViewModel_ textValue(@StringRes int stringRes, Object... formatArgs) {
onMutation();
assignedAttributes_epoxyGeneratedModel.set(0);
textValue_StringAttributeData.setValue(stringRes, formatArgs);
return this;
}
/**
* Throws if a value <= 0 is set.
* <p>
* <i>Required.</i>
*
* @see TestFieldPropChildView#textValue
*/
public TestFieldPropChildViewModel_ textValueQuantityRes(@PluralsRes int pluralRes, int quantity,
Object... formatArgs) {
onMutation();
assignedAttributes_epoxyGeneratedModel.set(0);
textValue_StringAttributeData.setValue(pluralRes, quantity, formatArgs);
return this;
}
/**
* Set a click listener that will provide the parent view, model, and adapter position of the clicked view. This will clear the normal View.OnClickListener if one has been set
*/
public TestFieldPropChildViewModel_ value(
@Nullable final OnModelClickListener<TestFieldPropChildViewModel_, TestFieldPropChildView> value) {
onMutation();
if (value == null) {
this.value_OnClickListener = null;
}
else {
this.value_OnClickListener = new WrappedEpoxyModelClickListener<>(value);
}
return this;
}
/**
* <i>Optional</i>: Default value is (View.OnClickListener) null
*
* @see TestFieldPropParentView#value
*/
public TestFieldPropChildViewModel_ value(@Nullable View.OnClickListener value) {
onMutation();
this.value_OnClickListener = value;
return this;
}
@Nullable
public View.OnClickListener value() {
return value_OnClickListener;
}
@Override
public TestFieldPropChildViewModel_ id(long id) {
super.id(id);
return this;
}
@Override
public TestFieldPropChildViewModel_ id(@androidx.annotation.Nullable Number... ids) {
super.id(ids);
return this;
}
@Override
public TestFieldPropChildViewModel_ id(long id1, long id2) {
super.id(id1, id2);
return this;
}
@Override
public TestFieldPropChildViewModel_ id(@androidx.annotation.Nullable CharSequence key) {
super.id(key);
return this;
}
@Override
public TestFieldPropChildViewModel_ id(@androidx.annotation.Nullable CharSequence key,
@androidx.annotation.Nullable CharSequence... otherKeys) {
super.id(key, otherKeys);
return this;
}
@Override
public TestFieldPropChildViewModel_ id(@androidx.annotation.Nullable CharSequence key, long id) {
super.id(key, id);
return this;
}
@Override
public TestFieldPropChildViewModel_ layout(@LayoutRes int layoutRes) {
throw new UnsupportedOperationException("Layout resources are unsupported with programmatic views.");
}
@Override
public TestFieldPropChildViewModel_ spanSizeOverride(
@androidx.annotation.Nullable EpoxyModel.SpanSizeOverrideCallback spanSizeCallback) {
super.spanSizeOverride(spanSizeCallback);
return this;
}
@Override
public TestFieldPropChildViewModel_ show() {
super.show();
return this;
}
@Override
public TestFieldPropChildViewModel_ show(boolean show) {
super.show(show);
return this;
}
@Override
public TestFieldPropChildViewModel_ hide() {
super.hide();
return this;
}
@Override
@LayoutRes
protected int getDefaultLayout() {
throw new UnsupportedOperationException("Layout resources are unsupported for views created programmatically.");
}
@Override
public TestFieldPropChildViewModel_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
assignedAttributes_epoxyGeneratedModel.clear();
this.textValue_StringAttributeData = new StringAttributeData();
this.value_OnClickListener = (View.OnClickListener) null;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof TestFieldPropChildViewModel_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
TestFieldPropChildViewModel_ that = (TestFieldPropChildViewModel_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((textValue_StringAttributeData != null ? !textValue_StringAttributeData.equals(that.textValue_StringAttributeData) : that.textValue_StringAttributeData != null)) {
return false;
}
if ((value_OnClickListener != null ? !value_OnClickListener.equals(that.value_OnClickListener) : that.value_OnClickListener != null)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (textValue_StringAttributeData != null ? textValue_StringAttributeData.hashCode() : 0);
_result = 31 * _result + (value_OnClickListener != null ? value_OnClickListener.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "TestFieldPropChildViewModel_{" +
"textValue_StringAttributeData=" + textValue_StringAttributeData +
", value_OnClickListener=" + value_OnClickListener +
"}" + super.toString();
}
@Override
public int getSpanSize(int totalSpanCount, int position, int itemCount) {
return totalSpanCount;
}
}
| 8,474 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/RequireAbstractModelFailsEpoxyModelClass.java | package com.airbnb.epoxy.configtest;
import com.airbnb.epoxy.EpoxyModel;
import com.airbnb.epoxy.EpoxyModelClass;
@EpoxyModelClass
public class RequireAbstractModelFailsEpoxyModelClass extends EpoxyModel<Object> {
@Override
protected int getDefaultLayout() {
return 0;
}
} | 8,475 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/AbstractModelWithHolder_.java | package com.airbnb.epoxy;
import android.view.ViewParent;
import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;
import java.lang.CharSequence;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
/**
* Generated file. Do not modify!
*/
public class AbstractModelWithHolder_ extends AbstractModelWithHolder implements GeneratedModel<AbstractModelWithHolder.Holder>, AbstractModelWithHolderBuilder {
private OnModelBoundListener<AbstractModelWithHolder_, AbstractModelWithHolder.Holder> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<AbstractModelWithHolder_, AbstractModelWithHolder.Holder> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<AbstractModelWithHolder_, AbstractModelWithHolder.Holder> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<AbstractModelWithHolder_, AbstractModelWithHolder.Holder> onModelVisibilityChangedListener_epoxyGeneratedModel;
public AbstractModelWithHolder_() {
super();
}
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
}
@Override
public void handlePreBind(final EpoxyViewHolder holder,
final AbstractModelWithHolder.Holder object, final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void handlePostBind(final AbstractModelWithHolder.Holder object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public AbstractModelWithHolder_ onBind(
OnModelBoundListener<AbstractModelWithHolder_, AbstractModelWithHolder.Holder> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(AbstractModelWithHolder.Holder object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public AbstractModelWithHolder_ onUnbind(
OnModelUnboundListener<AbstractModelWithHolder_, AbstractModelWithHolder.Holder> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState,
final AbstractModelWithHolder.Holder object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public AbstractModelWithHolder_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<AbstractModelWithHolder_, AbstractModelWithHolder.Holder> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final AbstractModelWithHolder.Holder object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public AbstractModelWithHolder_ onVisibilityChanged(
OnModelVisibilityChangedListener<AbstractModelWithHolder_, AbstractModelWithHolder.Holder> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
public AbstractModelWithHolder_ value(int value) {
onMutation();
super.value = value;
return this;
}
public int value() {
return value;
}
@Override
public AbstractModelWithHolder_ id(long id) {
super.id(id);
return this;
}
@Override
public AbstractModelWithHolder_ id(@Nullable Number... ids) {
super.id(ids);
return this;
}
@Override
public AbstractModelWithHolder_ id(long id1, long id2) {
super.id(id1, id2);
return this;
}
@Override
public AbstractModelWithHolder_ id(@Nullable CharSequence key) {
super.id(key);
return this;
}
@Override
public AbstractModelWithHolder_ id(@Nullable CharSequence key,
@Nullable CharSequence... otherKeys) {
super.id(key, otherKeys);
return this;
}
@Override
public AbstractModelWithHolder_ id(@Nullable CharSequence key, long id) {
super.id(key, id);
return this;
}
@Override
public AbstractModelWithHolder_ layout(@LayoutRes int layoutRes) {
super.layout(layoutRes);
return this;
}
@Override
public AbstractModelWithHolder_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback spanSizeCallback) {
super.spanSizeOverride(spanSizeCallback);
return this;
}
@Override
public AbstractModelWithHolder_ show() {
super.show();
return this;
}
@Override
public AbstractModelWithHolder_ show(boolean show) {
super.show(show);
return this;
}
@Override
public AbstractModelWithHolder_ hide() {
super.hide();
return this;
}
@Override
protected AbstractModelWithHolder.Holder createNewHolder(ViewParent parent) {
return new AbstractModelWithHolder.Holder();
}
@Override
public AbstractModelWithHolder_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
super.value = 0;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof AbstractModelWithHolder_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
AbstractModelWithHolder_ that = (AbstractModelWithHolder_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((value != that.value)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + value;
return _result;
}
@Override
public String toString() {
return "AbstractModelWithHolder_{" +
"value=" + value +
"}" + super.toString();
}
}
| 8,476 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/ModelViewWithParisModel_.java | package com.airbnb.epoxy;
import android.os.AsyncTask;
import android.view.ViewGroup;
import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;
import com.airbnb.paris.StyleApplierUtils;
import com.airbnb.paris.styles.Style;
import com.airbnb.viewmodeladapter.R;
import java.lang.AssertionError;
import java.lang.CharSequence;
import java.lang.IllegalStateException;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.Runnable;
import java.lang.String;
import java.lang.UnsupportedOperationException;
import java.lang.ref.WeakReference;
import java.util.Objects;
/**
* Generated file. Do not modify!
*/
public class ModelViewWithParisModel_ extends EpoxyModel<ModelViewWithParis> implements GeneratedModel<ModelViewWithParis>, ModelViewWithParisModelBuilder {
private static final Style DEFAULT_PARIS_STYLE = new ModelViewWithParisStyleApplier.StyleBuilder().addDefault().build();
private static WeakReference<Style> parisStyleReference_header;
private static WeakReference<Style> parisStyleReference_other;
private static WeakReference<Style> parisStyleReference_default;
private OnModelBoundListener<ModelViewWithParisModel_, ModelViewWithParis> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<ModelViewWithParisModel_, ModelViewWithParis> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<ModelViewWithParisModel_, ModelViewWithParis> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<ModelViewWithParisModel_, ModelViewWithParis> onModelVisibilityChangedListener_epoxyGeneratedModel;
private int value_Int = 0;
private Style style = DEFAULT_PARIS_STYLE;
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
}
@Override
protected int getViewType() {
return 0;
}
@Override
public ModelViewWithParis buildView(ViewGroup parent) {
ModelViewWithParis v = new ModelViewWithParis(parent.getContext());
v.setLayoutParams(new ViewGroup.MarginLayoutParams(ViewGroup.MarginLayoutParams.WRAP_CONTENT, ViewGroup.MarginLayoutParams.WRAP_CONTENT));
return v;
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final ModelViewWithParis object,
final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
if (!Objects.equals(style, object.getTag(R.id.epoxy_saved_view_style))) {
AsyncTask.THREAD_POOL_EXECUTOR.execute(new Runnable() {
public void run() {
try {
StyleApplierUtils.Companion.assertSameAttributes(new ModelViewWithParisStyleApplier(object), style, DEFAULT_PARIS_STYLE);
}
catch(AssertionError e) {
throw new IllegalStateException("ModelViewWithParisModel_ model at position " + position + " has an invalid style:\n\n" + e.getMessage());
}
}
} );
}
}
@Override
public void bind(final ModelViewWithParis object) {
if (!Objects.equals(style, object.getTag(R.id.epoxy_saved_view_style))) {
ModelViewWithParisStyleApplier styleApplier = new ModelViewWithParisStyleApplier(object);
styleApplier.apply(style);
object.setTag(R.id.epoxy_saved_view_style, style);
}
super.bind(object);
object.value = value_Int;
}
@Override
public void bind(final ModelViewWithParis object, EpoxyModel previousModel) {
if (!(previousModel instanceof ModelViewWithParisModel_)) {
bind(object);
return;
}
ModelViewWithParisModel_ that = (ModelViewWithParisModel_) previousModel;
if (!Objects.equals(style, that.style)) {
ModelViewWithParisStyleApplier styleApplier = new ModelViewWithParisStyleApplier(object);
styleApplier.apply(style);
object.setTag(R.id.epoxy_saved_view_style, style);
}
super.bind(object);
if ((value_Int != that.value_Int)) {
object.value = value_Int;
}
}
@Override
public void handlePostBind(final ModelViewWithParis object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ModelViewWithParisModel_ onBind(
OnModelBoundListener<ModelViewWithParisModel_, ModelViewWithParis> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(ModelViewWithParis object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ModelViewWithParisModel_ onUnbind(
OnModelUnboundListener<ModelViewWithParisModel_, ModelViewWithParis> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState, final ModelViewWithParis object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ModelViewWithParisModel_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<ModelViewWithParisModel_, ModelViewWithParis> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final ModelViewWithParis object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ModelViewWithParisModel_ onVisibilityChanged(
OnModelVisibilityChangedListener<ModelViewWithParisModel_, ModelViewWithParis> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
public ModelViewWithParisModel_ style(Style style) {
onMutation();
this.style = style;
return this;
}
public ModelViewWithParisModel_ styleBuilder(
StyleBuilderCallback<ModelViewWithParisStyleApplier.StyleBuilder> builderCallback) {
ModelViewWithParisStyleApplier.StyleBuilder builder = new ModelViewWithParisStyleApplier.StyleBuilder();
builderCallback.buildStyle(builder.addDefault());
return style(builder.build());
}
/**
* @see ModelViewWithParis#headerStyle(ModelViewWithParisStyleApplier.StyleBuilder)
*/
public ModelViewWithParisModel_ withHeaderStyle() {
Style style = parisStyleReference_header != null ? parisStyleReference_header.get() : null;
if (style == null) {
style = new ModelViewWithParisStyleApplier.StyleBuilder().addHeader().build();
parisStyleReference_header = new WeakReference<>(style);
}
return style(style);
}
/**
* @see ModelViewWithParis#otherStyle(ModelViewWithParisStyleApplier.StyleBuilder)
*/
public ModelViewWithParisModel_ withOtherStyle() {
Style style = parisStyleReference_other != null ? parisStyleReference_other.get() : null;
if (style == null) {
style = new ModelViewWithParisStyleApplier.StyleBuilder().addOther().build();
parisStyleReference_other = new WeakReference<>(style);
}
return style(style);
}
/**
* @see ModelViewWithParis#headerStyle(ModelViewWithParisStyleApplier.StyleBuilder)
*/
public ModelViewWithParisModel_ withDefaultStyle() {
Style style = parisStyleReference_default != null ? parisStyleReference_default.get() : null;
if (style == null) {
style = new ModelViewWithParisStyleApplier.StyleBuilder().addDefault().build();
parisStyleReference_default = new WeakReference<>(style);
}
return style(style);
}
/**
* <i>Optional</i>: Default value is 0
*
* @see ModelViewWithParis#value
*/
public ModelViewWithParisModel_ value(int value) {
onMutation();
this.value_Int = value;
return this;
}
public int value() {
return value_Int;
}
@Override
public ModelViewWithParisModel_ id(long id) {
super.id(id);
return this;
}
@Override
public ModelViewWithParisModel_ id(@Nullable Number... ids) {
super.id(ids);
return this;
}
@Override
public ModelViewWithParisModel_ id(long id1, long id2) {
super.id(id1, id2);
return this;
}
@Override
public ModelViewWithParisModel_ id(@Nullable CharSequence key) {
super.id(key);
return this;
}
@Override
public ModelViewWithParisModel_ id(@Nullable CharSequence key,
@Nullable CharSequence... otherKeys) {
super.id(key, otherKeys);
return this;
}
@Override
public ModelViewWithParisModel_ id(@Nullable CharSequence key, long id) {
super.id(key, id);
return this;
}
@Override
public ModelViewWithParisModel_ layout(@LayoutRes int layoutRes) {
throw new UnsupportedOperationException("Layout resources are unsupported with programmatic views.");
}
@Override
public ModelViewWithParisModel_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback spanSizeCallback) {
super.spanSizeOverride(spanSizeCallback);
return this;
}
@Override
public ModelViewWithParisModel_ show() {
super.show();
return this;
}
@Override
public ModelViewWithParisModel_ show(boolean show) {
super.show(show);
return this;
}
@Override
public ModelViewWithParisModel_ hide() {
super.hide();
return this;
}
@Override
@LayoutRes
protected int getDefaultLayout() {
throw new UnsupportedOperationException("Layout resources are unsupported for views created programmatically.");
}
@Override
public ModelViewWithParisModel_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
this.value_Int = 0;
this.style = DEFAULT_PARIS_STYLE;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof ModelViewWithParisModel_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
ModelViewWithParisModel_ that = (ModelViewWithParisModel_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((value_Int != that.value_Int)) {
return false;
}
if ((style != null ? !style.equals(that.style) : that.style != null)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + value_Int;
_result = 31 * _result + (style != null ? style.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "ModelViewWithParisModel_{" +
"value_Int=" + value_Int +
", style=" + style +
"}" + super.toString();
}
@Override
public int getSpanSize(int totalSpanCount, int position, int itemCount) {
return totalSpanCount;
}
}
| 8,477 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/ModelWithVarargsConstructors.java | package com.airbnb.epoxy;
public class ModelWithVarargsConstructors extends EpoxyModel<Object> {
@EpoxyAttribute int valueInt;
@EpoxyAttribute String[] varargs;
public ModelWithVarargsConstructors(String... varargs) {
this.varargs = varargs;
}
public ModelWithVarargsConstructors(int valueInt, String... varargs) {
this.valueInt = valueInt;
this.varargs = varargs;
}
@Override
protected int getDefaultLayout() {
return 0;
}
} | 8,478 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/GridSpanCountView.java | package com.airbnb.epoxy;
import android.content.Context;
import android.view.View;
@ModelView(defaultLayout = 1, fullSpan = false)
public class GridSpanCountView extends View {
public GridSpanCountView(Context context) {
super(context);
}
@ModelProp
public void setClickListener(String title) {
}
} | 8,479 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/TestNullStringOverloadsView.java | package com.airbnb.epoxy;
import android.content.Context;
import androidx.annotation.Nullable;
import android.view.View;
@ModelView(defaultLayout = 1)
public class TestNullStringOverloadsView extends View {
public TestNullStringOverloadsView(Context context) {
super(context);
}
@ModelProp(options = ModelProp.Option.GenerateStringOverloads)
public void setTitle(@Nullable CharSequence title) {
}
}
| 8,480 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/ModelWithViewClickListener_.java | package com.airbnb.epoxy;
import android.view.View;
import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;
import java.lang.CharSequence;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
/**
* Generated file. Do not modify!
*/
public class ModelWithViewClickListener_ extends ModelWithViewClickListener implements GeneratedModel<Object>, ModelWithViewClickListenerBuilder {
private OnModelBoundListener<ModelWithViewClickListener_, Object> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<ModelWithViewClickListener_, Object> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<ModelWithViewClickListener_, Object> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<ModelWithViewClickListener_, Object> onModelVisibilityChangedListener_epoxyGeneratedModel;
public ModelWithViewClickListener_() {
super();
}
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final Object object, final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void handlePostBind(final Object object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ModelWithViewClickListener_ onBind(
OnModelBoundListener<ModelWithViewClickListener_, Object> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(Object object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ModelWithViewClickListener_ onUnbind(
OnModelUnboundListener<ModelWithViewClickListener_, Object> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState, final Object object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ModelWithViewClickListener_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<ModelWithViewClickListener_, Object> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final Object object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ModelWithViewClickListener_ onVisibilityChanged(
OnModelVisibilityChangedListener<ModelWithViewClickListener_, Object> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
/**
* Set a click listener that will provide the parent view, model, and adapter position of the clicked view. This will clear the normal View.OnClickListener if one has been set
*/
public ModelWithViewClickListener_ clickListener(
final OnModelClickListener<ModelWithViewClickListener_, Object> clickListener) {
onMutation();
if (clickListener == null) {
super.clickListener = null;
}
else {
super.clickListener = new WrappedEpoxyModelClickListener<>(clickListener);
}
return this;
}
public ModelWithViewClickListener_ clickListener(View.OnClickListener clickListener) {
onMutation();
super.clickListener = clickListener;
return this;
}
public View.OnClickListener clickListener() {
return clickListener;
}
@Override
public ModelWithViewClickListener_ id(long id) {
super.id(id);
return this;
}
@Override
public ModelWithViewClickListener_ id(@Nullable Number... ids) {
super.id(ids);
return this;
}
@Override
public ModelWithViewClickListener_ id(long id1, long id2) {
super.id(id1, id2);
return this;
}
@Override
public ModelWithViewClickListener_ id(@Nullable CharSequence key) {
super.id(key);
return this;
}
@Override
public ModelWithViewClickListener_ id(@Nullable CharSequence key,
@Nullable CharSequence... otherKeys) {
super.id(key, otherKeys);
return this;
}
@Override
public ModelWithViewClickListener_ id(@Nullable CharSequence key, long id) {
super.id(key, id);
return this;
}
@Override
public ModelWithViewClickListener_ layout(@LayoutRes int layoutRes) {
super.layout(layoutRes);
return this;
}
@Override
public ModelWithViewClickListener_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback spanSizeCallback) {
super.spanSizeOverride(spanSizeCallback);
return this;
}
@Override
public ModelWithViewClickListener_ show() {
super.show();
return this;
}
@Override
public ModelWithViewClickListener_ show(boolean show) {
super.show(show);
return this;
}
@Override
public ModelWithViewClickListener_ hide() {
super.hide();
return this;
}
@Override
public ModelWithViewClickListener_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
super.clickListener = null;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof ModelWithViewClickListener_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
ModelWithViewClickListener_ that = (ModelWithViewClickListener_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((clickListener == null) != (that.clickListener == null))) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (clickListener != null ? 1 : 0);
return _result;
}
@Override
public String toString() {
return "ModelWithViewClickListener_{" +
"clickListener=" + clickListener +
"}" + super.toString();
}
}
| 8,481 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/ControllerWithAutoModelWithoutValidation_EpoxyHelper.java | package com.airbnb.epoxy.adapter;
import com.airbnb.epoxy.BasicModelWithAttribute_;
import com.airbnb.epoxy.ControllerHelper;
import java.lang.Override;
/**
* Generated file. Do not modify! */
public class ControllerWithAutoModelWithoutValidation_EpoxyHelper extends ControllerHelper<ControllerWithAutoModelWithoutValidation> {
private final ControllerWithAutoModelWithoutValidation controller;
public ControllerWithAutoModelWithoutValidation_EpoxyHelper(
ControllerWithAutoModelWithoutValidation controller) {
this.controller = controller;
}
@Override
public void resetAutoModels() {
controller.modelWithAttribute2 = new BasicModelWithAttribute_();
controller.modelWithAttribute2.id(-1);
controller.modelWithAttribute1 = new BasicModelWithAttribute_();
controller.modelWithAttribute1.id(-2);
}
} | 8,482 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/ModelWithType.java | package com.airbnb.epoxy;
public class ModelWithType<T extends String> extends EpoxyModel<Object> {
@EpoxyAttribute int value;
@Override
protected int getDefaultLayout() {
return 0;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof ModelWithType_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
ModelWithType that = (ModelWithType) o;
return value == that.value;
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + value;
return result;
}
} | 8,483 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/AutoLayoutModelView.java | package com.airbnb.epoxy;
import android.content.Context;
import android.view.View;
@ModelView(autoLayout = ModelView.Size.WRAP_WIDTH_WRAP_HEIGHT)
public class AutoLayoutModelView extends View {
public AutoLayoutModelView(Context context) {
super(context);
}
@ModelProp
void setValue(int value) {
}
} | 8,484 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/ControllerWithAutoModelWithSuperClass.java | package com.airbnb.epoxy.adapter;
import com.airbnb.epoxy.AutoModel;
import com.airbnb.epoxy.BasicModelWithAttribute_;
import com.airbnb.epoxy.EpoxyController;
public class ControllerWithAutoModelWithSuperClass extends EpoxyController {
@AutoModel BasicModelWithAttribute_ modelWithAttribute1;
@AutoModel BasicModelWithAttribute_ modelWithAttribute2;
@Override
protected void buildModels() {
}
public static class SubControllerWithAutoModelWithSuperClass extends ControllerWithAutoModelWithSuperClass {
@AutoModel BasicModelWithAttribute_ modelWithAttribute3;
@Override
protected void buildModels() {
}
}
} | 8,485 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/ModelWithViewLongClickListener_.java | package com.airbnb.epoxy;
import android.view.View;
import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;
import java.lang.CharSequence;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
/**
* Generated file. Do not modify!
*/
public class ModelWithViewLongClickListener_ extends ModelWithViewLongClickListener implements GeneratedModel<Object>, ModelWithViewLongClickListenerBuilder {
private OnModelBoundListener<ModelWithViewLongClickListener_, Object> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<ModelWithViewLongClickListener_, Object> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<ModelWithViewLongClickListener_, Object> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<ModelWithViewLongClickListener_, Object> onModelVisibilityChangedListener_epoxyGeneratedModel;
public ModelWithViewLongClickListener_() {
super();
}
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final Object object, final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void handlePostBind(final Object object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ModelWithViewLongClickListener_ onBind(
OnModelBoundListener<ModelWithViewLongClickListener_, Object> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(Object object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ModelWithViewLongClickListener_ onUnbind(
OnModelUnboundListener<ModelWithViewLongClickListener_, Object> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState, final Object object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ModelWithViewLongClickListener_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<ModelWithViewLongClickListener_, Object> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final Object object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ModelWithViewLongClickListener_ onVisibilityChanged(
OnModelVisibilityChangedListener<ModelWithViewLongClickListener_, Object> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
/**
* Set a click listener that will provide the parent view, model, and adapter position of the clicked view. This will clear the normal View.OnClickListener if one has been set
*/
public ModelWithViewLongClickListener_ clickListener(
final OnModelLongClickListener<ModelWithViewLongClickListener_, Object> clickListener) {
onMutation();
if (clickListener == null) {
super.clickListener = null;
}
else {
super.clickListener = new WrappedEpoxyModelClickListener<>(clickListener);
}
return this;
}
public ModelWithViewLongClickListener_ clickListener(View.OnLongClickListener clickListener) {
onMutation();
super.clickListener = clickListener;
return this;
}
public View.OnLongClickListener clickListener() {
return clickListener;
}
@Override
public ModelWithViewLongClickListener_ id(long id) {
super.id(id);
return this;
}
@Override
public ModelWithViewLongClickListener_ id(@Nullable Number... ids) {
super.id(ids);
return this;
}
@Override
public ModelWithViewLongClickListener_ id(long id1, long id2) {
super.id(id1, id2);
return this;
}
@Override
public ModelWithViewLongClickListener_ id(@Nullable CharSequence key) {
super.id(key);
return this;
}
@Override
public ModelWithViewLongClickListener_ id(@Nullable CharSequence key,
@Nullable CharSequence... otherKeys) {
super.id(key, otherKeys);
return this;
}
@Override
public ModelWithViewLongClickListener_ id(@Nullable CharSequence key, long id) {
super.id(key, id);
return this;
}
@Override
public ModelWithViewLongClickListener_ layout(@LayoutRes int layoutRes) {
super.layout(layoutRes);
return this;
}
@Override
public ModelWithViewLongClickListener_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback spanSizeCallback) {
super.spanSizeOverride(spanSizeCallback);
return this;
}
@Override
public ModelWithViewLongClickListener_ show() {
super.show();
return this;
}
@Override
public ModelWithViewLongClickListener_ show(boolean show) {
super.show(show);
return this;
}
@Override
public ModelWithViewLongClickListener_ hide() {
super.hide();
return this;
}
@Override
public ModelWithViewLongClickListener_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
super.clickListener = null;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof ModelWithViewLongClickListener_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
ModelWithViewLongClickListener_ that = (ModelWithViewLongClickListener_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((clickListener == null) != (that.clickListener == null))) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (clickListener != null ? 1 : 0);
return _result;
}
@Override
public String toString() {
return "ModelWithViewLongClickListener_{" +
"clickListener=" + clickListener +
"}" + super.toString();
}
}
| 8,486 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/BasicModelWithAttribute_.java | package com.airbnb.epoxy;
import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;
import java.lang.CharSequence;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
/**
* Generated file. Do not modify!
*/
public class BasicModelWithAttribute_ extends BasicModelWithAttribute implements GeneratedModel<Object>, BasicModelWithAttributeBuilder {
private OnModelBoundListener<BasicModelWithAttribute_, Object> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<BasicModelWithAttribute_, Object> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<BasicModelWithAttribute_, Object> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<BasicModelWithAttribute_, Object> onModelVisibilityChangedListener_epoxyGeneratedModel;
public BasicModelWithAttribute_() {
super();
}
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final Object object, final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void handlePostBind(final Object object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public BasicModelWithAttribute_ onBind(
OnModelBoundListener<BasicModelWithAttribute_, Object> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(Object object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public BasicModelWithAttribute_ onUnbind(
OnModelUnboundListener<BasicModelWithAttribute_, Object> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState, final Object object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public BasicModelWithAttribute_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<BasicModelWithAttribute_, Object> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final Object object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public BasicModelWithAttribute_ onVisibilityChanged(
OnModelVisibilityChangedListener<BasicModelWithAttribute_, Object> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
public BasicModelWithAttribute_ value(int value) {
onMutation();
super.value = value;
return this;
}
public int value() {
return value;
}
@Override
public BasicModelWithAttribute_ id(long id) {
super.id(id);
return this;
}
@Override
public BasicModelWithAttribute_ id(@Nullable Number... ids) {
super.id(ids);
return this;
}
@Override
public BasicModelWithAttribute_ id(long id1, long id2) {
super.id(id1, id2);
return this;
}
@Override
public BasicModelWithAttribute_ id(@Nullable CharSequence key) {
super.id(key);
return this;
}
@Override
public BasicModelWithAttribute_ id(@Nullable CharSequence key,
@Nullable CharSequence... otherKeys) {
super.id(key, otherKeys);
return this;
}
@Override
public BasicModelWithAttribute_ id(@Nullable CharSequence key, long id) {
super.id(key, id);
return this;
}
@Override
public BasicModelWithAttribute_ layout(@LayoutRes int layoutRes) {
super.layout(layoutRes);
return this;
}
@Override
public BasicModelWithAttribute_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback spanSizeCallback) {
super.spanSizeOverride(spanSizeCallback);
return this;
}
@Override
public BasicModelWithAttribute_ show() {
super.show();
return this;
}
@Override
public BasicModelWithAttribute_ show(boolean show) {
super.show(show);
return this;
}
@Override
public BasicModelWithAttribute_ hide() {
super.hide();
return this;
}
@Override
public BasicModelWithAttribute_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
super.value = 0;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof BasicModelWithAttribute_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
BasicModelWithAttribute_ that = (BasicModelWithAttribute_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((value != that.value)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + value;
return _result;
}
@Override
public String toString() {
return "BasicModelWithAttribute_{" +
"value=" + value +
"}" + super.toString();
}
}
| 8,487 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/ModelWithType_.java | package com.airbnb.epoxy;
import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;
import java.lang.CharSequence;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
/**
* Generated file. Do not modify!
*/
public class ModelWithType_<T extends String> extends ModelWithType<T> implements GeneratedModel<Object>, ModelWithTypeBuilder<T> {
private OnModelBoundListener<ModelWithType_<T>, Object> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<ModelWithType_<T>, Object> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<ModelWithType_<T>, Object> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<ModelWithType_<T>, Object> onModelVisibilityChangedListener_epoxyGeneratedModel;
public ModelWithType_() {
super();
}
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final Object object, final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void handlePostBind(final Object object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ModelWithType_<T> onBind(OnModelBoundListener<ModelWithType_<T>, Object> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(Object object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ModelWithType_<T> onUnbind(OnModelUnboundListener<ModelWithType_<T>, Object> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState, final Object object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ModelWithType_<T> onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<ModelWithType_<T>, Object> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final Object object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ModelWithType_<T> onVisibilityChanged(
OnModelVisibilityChangedListener<ModelWithType_<T>, Object> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
public ModelWithType_<T> value(int value) {
onMutation();
super.value = value;
return this;
}
public int value() {
return value;
}
@Override
public ModelWithType_<T> id(long id) {
super.id(id);
return this;
}
@Override
public ModelWithType_<T> id(@Nullable Number... ids) {
super.id(ids);
return this;
}
@Override
public ModelWithType_<T> id(long id1, long id2) {
super.id(id1, id2);
return this;
}
@Override
public ModelWithType_<T> id(@Nullable CharSequence key) {
super.id(key);
return this;
}
@Override
public ModelWithType_<T> id(@Nullable CharSequence key, @Nullable CharSequence... otherKeys) {
super.id(key, otherKeys);
return this;
}
@Override
public ModelWithType_<T> id(@Nullable CharSequence key, long id) {
super.id(key, id);
return this;
}
@Override
public ModelWithType_<T> layout(@LayoutRes int layoutRes) {
super.layout(layoutRes);
return this;
}
@Override
public ModelWithType_<T> spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback spanSizeCallback) {
super.spanSizeOverride(spanSizeCallback);
return this;
}
@Override
public ModelWithType_<T> show() {
super.show();
return this;
}
@Override
public ModelWithType_<T> show(boolean show) {
super.show(show);
return this;
}
@Override
public ModelWithType_<T> hide() {
super.hide();
return this;
}
@Override
public ModelWithType_<T> reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
super.value = 0;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof ModelWithType_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
ModelWithType_ that = (ModelWithType_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((value != that.value)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + value;
return _result;
}
@Override
public String toString() {
return "ModelWithType_{" +
"value=" + value +
"}" + super.toString();
}
}
| 8,488 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodNextParentLayout$NoLayout_.java | package com.airbnb.epoxy;
import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;
import java.lang.CharSequence;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
/**
* Generated file. Do not modify!
*/
public class GenerateDefaultLayoutMethodNextParentLayout$NoLayout_ extends GenerateDefaultLayoutMethodNextParentLayout.NoLayout implements GeneratedModel<Object>, GenerateDefaultLayoutMethodNextParentLayout_NoLayoutBuilder {
private OnModelBoundListener<GenerateDefaultLayoutMethodNextParentLayout$NoLayout_, Object> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<GenerateDefaultLayoutMethodNextParentLayout$NoLayout_, Object> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<GenerateDefaultLayoutMethodNextParentLayout$NoLayout_, Object> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<GenerateDefaultLayoutMethodNextParentLayout$NoLayout_, Object> onModelVisibilityChangedListener_epoxyGeneratedModel;
public GenerateDefaultLayoutMethodNextParentLayout$NoLayout_() {
super();
}
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final Object object, final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void handlePostBind(final Object object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public GenerateDefaultLayoutMethodNextParentLayout$NoLayout_ onBind(
OnModelBoundListener<GenerateDefaultLayoutMethodNextParentLayout$NoLayout_, Object> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(Object object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public GenerateDefaultLayoutMethodNextParentLayout$NoLayout_ onUnbind(
OnModelUnboundListener<GenerateDefaultLayoutMethodNextParentLayout$NoLayout_, Object> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState, final Object object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public GenerateDefaultLayoutMethodNextParentLayout$NoLayout_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<GenerateDefaultLayoutMethodNextParentLayout$NoLayout_, Object> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final Object object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public GenerateDefaultLayoutMethodNextParentLayout$NoLayout_ onVisibilityChanged(
OnModelVisibilityChangedListener<GenerateDefaultLayoutMethodNextParentLayout$NoLayout_, Object> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
public GenerateDefaultLayoutMethodNextParentLayout$NoLayout_ value(int value) {
onMutation();
super.value = value;
return this;
}
public int value() {
return value;
}
@Override
public GenerateDefaultLayoutMethodNextParentLayout$NoLayout_ id(long id) {
super.id(id);
return this;
}
@Override
public GenerateDefaultLayoutMethodNextParentLayout$NoLayout_ id(@Nullable Number... ids) {
super.id(ids);
return this;
}
@Override
public GenerateDefaultLayoutMethodNextParentLayout$NoLayout_ id(long id1, long id2) {
super.id(id1, id2);
return this;
}
@Override
public GenerateDefaultLayoutMethodNextParentLayout$NoLayout_ id(@Nullable CharSequence key) {
super.id(key);
return this;
}
@Override
public GenerateDefaultLayoutMethodNextParentLayout$NoLayout_ id(@Nullable CharSequence key,
@Nullable CharSequence... otherKeys) {
super.id(key, otherKeys);
return this;
}
@Override
public GenerateDefaultLayoutMethodNextParentLayout$NoLayout_ id(@Nullable CharSequence key,
long id) {
super.id(key, id);
return this;
}
@Override
public GenerateDefaultLayoutMethodNextParentLayout$NoLayout_ layout(@LayoutRes int layoutRes) {
super.layout(layoutRes);
return this;
}
@Override
public GenerateDefaultLayoutMethodNextParentLayout$NoLayout_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback spanSizeCallback) {
super.spanSizeOverride(spanSizeCallback);
return this;
}
@Override
public GenerateDefaultLayoutMethodNextParentLayout$NoLayout_ show() {
super.show();
return this;
}
@Override
public GenerateDefaultLayoutMethodNextParentLayout$NoLayout_ show(boolean show) {
super.show(show);
return this;
}
@Override
public GenerateDefaultLayoutMethodNextParentLayout$NoLayout_ hide() {
super.hide();
return this;
}
@Override
@LayoutRes
protected int getDefaultLayout() {
return 1;
}
@Override
public GenerateDefaultLayoutMethodNextParentLayout$NoLayout_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
super.value = 0;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof GenerateDefaultLayoutMethodNextParentLayout$NoLayout_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
GenerateDefaultLayoutMethodNextParentLayout$NoLayout_ that = (GenerateDefaultLayoutMethodNextParentLayout$NoLayout_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((value != that.value)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + value;
return _result;
}
@Override
public String toString() {
return "GenerateDefaultLayoutMethodNextParentLayout$NoLayout_{" +
"value=" + value +
"}" + super.toString();
}
}
| 8,489 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/ControllerWithAutoModelAndImplicitAdding_EpoxyHelper.java | package com.airbnb.epoxy.adapter;
import com.airbnb.epoxy.BasicModelWithAttribute_;
import com.airbnb.epoxy.ControllerHelper;
import com.airbnb.epoxy.EpoxyModel;
import java.lang.IllegalStateException;
import java.lang.Override;
import java.lang.String;
/**
* Generated file. Do not modify! */
public class ControllerWithAutoModelAndImplicitAdding_EpoxyHelper extends ControllerHelper<ControllerWithAutoModelAndImplicitAdding> {
private final ControllerWithAutoModelAndImplicitAdding controller;
private EpoxyModel modelWithAttribute2;
private EpoxyModel modelWithAttribute1;
public ControllerWithAutoModelAndImplicitAdding_EpoxyHelper(
ControllerWithAutoModelAndImplicitAdding controller) {
this.controller = controller;
}
@Override
public void resetAutoModels() {
validateModelsHaveNotChanged();
controller.modelWithAttribute2 = new BasicModelWithAttribute_();
controller.modelWithAttribute2.id(-1);
setControllerToStageTo(controller.modelWithAttribute2, controller);
controller.modelWithAttribute1 = new BasicModelWithAttribute_();
controller.modelWithAttribute1.id(-2);
setControllerToStageTo(controller.modelWithAttribute1, controller);
saveModelsForNextValidation();
}
private void validateModelsHaveNotChanged() {
validateSameModel(modelWithAttribute2, controller.modelWithAttribute2, "modelWithAttribute2", -1);
validateSameModel(modelWithAttribute1, controller.modelWithAttribute1, "modelWithAttribute1", -2);
validateModelHashCodesHaveNotChanged(controller);
}
private void validateSameModel(EpoxyModel expectedObject, EpoxyModel actualObject,
String fieldName, int id) {
if (expectedObject != actualObject) {
throw new IllegalStateException("Fields annotated with AutoModel cannot be directly assigned. The controller manages these fields for you. (" + controller.getClass().getSimpleName() + "#" + fieldName + ")");
}
if (actualObject != null && actualObject.id() != id) {
throw new IllegalStateException("Fields annotated with AutoModel cannot have their id changed manually. The controller manages the ids of these models for you. (" + controller.getClass().getSimpleName() + "#" + fieldName + ")");
}
}
private void saveModelsForNextValidation() {
modelWithAttribute2 = controller.modelWithAttribute2;
modelWithAttribute1 = controller.modelWithAttribute1;
}
} | 8,490 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/ModelWithVarargsConstructors_.java |
package com.airbnb.epoxy;
import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;
import java.lang.CharSequence;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.util.Arrays;
/**
* Generated file. Do not modify!
*/
public class ModelWithVarargsConstructors_ extends ModelWithVarargsConstructors implements GeneratedModel<Object>, ModelWithVarargsConstructorsBuilder {
private OnModelBoundListener<ModelWithVarargsConstructors_, Object> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<ModelWithVarargsConstructors_, Object> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<ModelWithVarargsConstructors_, Object> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<ModelWithVarargsConstructors_, Object> onModelVisibilityChangedListener_epoxyGeneratedModel;
public ModelWithVarargsConstructors_(String... varargs) {
super(varargs);
}
public ModelWithVarargsConstructors_(int valueInt, String... varargs) {
super(valueInt, varargs);
}
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final Object object, final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void handlePostBind(final Object object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ModelWithVarargsConstructors_ onBind(
OnModelBoundListener<ModelWithVarargsConstructors_, Object> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(Object object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ModelWithVarargsConstructors_ onUnbind(
OnModelUnboundListener<ModelWithVarargsConstructors_, Object> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState, final Object object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ModelWithVarargsConstructors_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<ModelWithVarargsConstructors_, Object> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final Object object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ModelWithVarargsConstructors_ onVisibilityChanged(
OnModelVisibilityChangedListener<ModelWithVarargsConstructors_, Object> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
public ModelWithVarargsConstructors_ valueInt(int valueInt) {
onMutation();
super.valueInt = valueInt;
return this;
}
public int valueInt() {
return valueInt;
}
public ModelWithVarargsConstructors_ varargs(String[] varargs) {
onMutation();
super.varargs = varargs;
return this;
}
public String[] varargs() {
return varargs;
}
@Override
public ModelWithVarargsConstructors_ id(long id) {
super.id(id);
return this;
}
@Override
public ModelWithVarargsConstructors_ id(@Nullable Number... ids) {
super.id(ids);
return this;
}
@Override
public ModelWithVarargsConstructors_ id(long id1, long id2) {
super.id(id1, id2);
return this;
}
@Override
public ModelWithVarargsConstructors_ id(@Nullable CharSequence key) {
super.id(key);
return this;
}
@Override
public ModelWithVarargsConstructors_ id(@Nullable CharSequence key,
@Nullable CharSequence... otherKeys) {
super.id(key, otherKeys);
return this;
}
@Override
public ModelWithVarargsConstructors_ id(@Nullable CharSequence key, long id) {
super.id(key, id);
return this;
}
@Override
public ModelWithVarargsConstructors_ layout(@LayoutRes int layoutRes) {
super.layout(layoutRes);
return this;
}
@Override
public ModelWithVarargsConstructors_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback spanSizeCallback) {
super.spanSizeOverride(spanSizeCallback);
return this;
}
@Override
public ModelWithVarargsConstructors_ show() {
super.show();
return this;
}
@Override
public ModelWithVarargsConstructors_ show(boolean show) {
super.show(show);
return this;
}
@Override
public ModelWithVarargsConstructors_ hide() {
super.hide();
return this;
}
@Override
public ModelWithVarargsConstructors_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
super.valueInt = 0;
super.varargs = null;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof ModelWithVarargsConstructors_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
ModelWithVarargsConstructors_ that = (ModelWithVarargsConstructors_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((valueInt != that.valueInt)) {
return false;
}
if (!Arrays.equals(varargs, that.varargs)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + valueInt;
_result = 31 * _result + Arrays.hashCode(varargs);
return _result;
}
@Override
public String toString() {
return "ModelWithVarargsConstructors_{" +
"valueInt=" + valueInt +
", varargs=" + varargs +
"}" + super.toString();
}
}
| 8,491 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/ModelWithPrivateFieldWithPrivateGetter.java | package com.airbnb.epoxy;
public class ModelWithPrivateFieldWithPrivateGetter extends EpoxyModel<Object> {
@EpoxyAttribute private int valueInt;
@Override
protected int getDefaultLayout() {
return 0;
}
private int getValueInt() {
return valueInt;
}
public void setValueInt(int valueInt) {
this.valueInt = valueInt;
}
} | 8,492 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_.java | package com.airbnb.epoxy;
import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;
import java.lang.CharSequence;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
/**
* Generated file. Do not modify!
*/
public class ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_ extends ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName implements GeneratedModel<Object>, ModelWithPrivateFieldWithSameAsFieldGetterAndSetterNameBuilder {
private OnModelBoundListener<ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_, Object> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_, Object> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_, Object> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_, Object> onModelVisibilityChangedListener_epoxyGeneratedModel;
public ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_() {
super();
}
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final Object object, final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void handlePostBind(final Object object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_ onBind(
OnModelBoundListener<ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_, Object> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(Object object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_ onUnbind(
OnModelUnboundListener<ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_, Object> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState, final Object object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_, Object> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final Object object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_ onVisibilityChanged(
OnModelVisibilityChangedListener<ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_, Object> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
public ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_ isValue(boolean isValue) {
onMutation();
super.setValue(isValue);
return this;
}
public boolean isValue() {
return super.isValue();
}
@Override
public ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_ id(long id) {
super.id(id);
return this;
}
@Override
public ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_ id(@Nullable Number... ids) {
super.id(ids);
return this;
}
@Override
public ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_ id(long id1, long id2) {
super.id(id1, id2);
return this;
}
@Override
public ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_ id(@Nullable CharSequence key) {
super.id(key);
return this;
}
@Override
public ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_ id(@Nullable CharSequence key,
@Nullable CharSequence... otherKeys) {
super.id(key, otherKeys);
return this;
}
@Override
public ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_ id(@Nullable CharSequence key,
long id) {
super.id(key, id);
return this;
}
@Override
public ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_ layout(@LayoutRes int layoutRes) {
super.layout(layoutRes);
return this;
}
@Override
public ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback spanSizeCallback) {
super.spanSizeOverride(spanSizeCallback);
return this;
}
@Override
public ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_ show() {
super.show();
return this;
}
@Override
public ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_ show(boolean show) {
super.show(show);
return this;
}
@Override
public ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_ hide() {
super.hide();
return this;
}
@Override
public ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
super.setValue(false);
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_ that = (ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((isValue() != that.isValue())) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (isValue() ? 1 : 0);
return _result;
}
@Override
public String toString() {
return "ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_{" +
"isValue=" + isValue() +
"}" + super.toString();
}
}
| 8,493 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/OnViewRecycledView_throwsIfStatic.java | package com.airbnb.epoxy;
import android.content.Context;
import android.view.View;
@ModelView(defaultLayout = 1)
public class OnViewRecycledView_throwsIfStatic extends View {
public OnViewRecycledView_throwsIfStatic(Context context) {
super(context);
}
@ModelProp
public void setTitle(CharSequence title) {
}
@OnViewRecycled
static void onRecycled1() {
}
} | 8,494 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/PropGroupsView.java | package com.airbnb.epoxy;
import android.content.Context;
import androidx.annotation.Nullable;
import android.view.View;
@ModelView(defaultLayout = 1)
public class PropGroupsView extends View {
static final long DEFAULT_PRIMITIVE = 234;
public PropGroupsView(Context context) {
super(context);
}
@ModelProp
public void setSomething(@Nullable CharSequence title) {
// The default value for this group should be to set null on this prop, since that is clearer
// than setting 0 on the primitive prop
}
@ModelProp
public void setSomething(int title) {
// Implicit grouping by having the same method name
}
@ModelProp
public void setSomethingElse(CharSequence title) {
}
@ModelProp
public void setSomethingElse(int title) {
// Implicit grouping by having the same method name
}
@ModelProp
public void setPrimitive(int title) {
}
@ModelProp
public void setPrimitive(long title) {
// Implicit grouping by having the same method name
// This should be optional, with the default value being either primitive prop (it is
// undefined which is used)
}
@ModelProp
public void setPrimitiveWithDefault(int title) {
}
@ModelProp(defaultValue = "DEFAULT_PRIMITIVE")
public void setPrimitiveWithDefault(long title) {
// Implicit grouping by having the same method name
// This should be optional, with the specified default
}
@ModelProp(defaultValue = "DEFAULT_PRIMITIVE")
public void primitiveAndObjectGroupWithPrimitiveDefault(long title) {
}
@ModelProp
public void primitiveAndObjectGroupWithPrimitiveDefault(CharSequence title) {
}
@ModelProp(group = "myGroup")
public void setOneThing(long title) {
}
@ModelProp(group = "myGroup")
public void setAnotherThing(CharSequence title) {
// should be in same group because of group key
}
@ModelProp
public void requiredGroup(String title) {
}
@ModelProp
public void requiredGroup(CharSequence title) {
}
}
| 8,495 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/TestManyTypesViewModelBuilder.java | package com.airbnb.epoxy;
import android.view.View;
import androidx.annotation.Dimension;
import androidx.annotation.IntRange;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.PluralsRes;
import androidx.annotation.StringRes;
import java.lang.Boolean;
import java.lang.CharSequence;
import java.lang.Integer;
import java.lang.Number;
import java.lang.Object;
import java.lang.String;
import java.util.List;
import java.util.Map;
import kotlin.jvm.functions.Function3;
@EpoxyBuildScope
public interface TestManyTypesViewModelBuilder {
TestManyTypesViewModelBuilder onBind(
OnModelBoundListener<TestManyTypesViewModel_, TestManyTypesView> listener);
TestManyTypesViewModelBuilder onUnbind(
OnModelUnboundListener<TestManyTypesViewModel_, TestManyTypesView> listener);
TestManyTypesViewModelBuilder onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<TestManyTypesViewModel_, TestManyTypesView> listener);
TestManyTypesViewModelBuilder onVisibilityChanged(
OnModelVisibilityChangedListener<TestManyTypesViewModel_, TestManyTypesView> listener);
TestManyTypesViewModelBuilder stringValue(@NonNull String stringValue);
TestManyTypesViewModelBuilder nullableStringValue(@Nullable String nullableStringValue);
TestManyTypesViewModelBuilder function(
@NonNull Function3<Integer, Integer, Integer, Integer> function);
TestManyTypesViewModelBuilder intValue(int intValue);
TestManyTypesViewModelBuilder intValueWithAnnotation(@StringRes int intValueWithAnnotation);
TestManyTypesViewModelBuilder intValueWithRangeAnnotation(
@IntRange(from = 0, to = 200) int intValueWithRangeAnnotation);
TestManyTypesViewModelBuilder intValueWithDimenTypeAnnotation(
@Dimension(unit = 0) int intValueWithDimenTypeAnnotation);
TestManyTypesViewModelBuilder intWithMultipleAnnotations(
@IntRange(from = 0, to = 200) @Dimension(unit = 0) int intWithMultipleAnnotations);
TestManyTypesViewModelBuilder integerValue(@NonNull Integer integerValue);
TestManyTypesViewModelBuilder boolValue(boolean boolValue);
TestManyTypesViewModelBuilder models(@NonNull List<? extends EpoxyModel<?>> models);
TestManyTypesViewModelBuilder booleanValue(@NonNull Boolean booleanValue);
TestManyTypesViewModelBuilder arrayValue(@NonNull String[] arrayValue);
TestManyTypesViewModelBuilder listValue(@NonNull List<String> listValue);
TestManyTypesViewModelBuilder mapValue(@NonNull Map<Integer, Integer> mapValue);
TestManyTypesViewModelBuilder clickListener(
@NonNull final OnModelClickListener<TestManyTypesViewModel_, TestManyTypesView> clickListener);
TestManyTypesViewModelBuilder clickListener(@NonNull View.OnClickListener clickListener);
TestManyTypesViewModelBuilder title(@Nullable CharSequence title);
TestManyTypesViewModelBuilder title(@StringRes int stringRes);
TestManyTypesViewModelBuilder title(@StringRes int stringRes, Object... formatArgs);
TestManyTypesViewModelBuilder titleQuantityRes(@PluralsRes int pluralRes, int quantity,
Object... formatArgs);
TestManyTypesViewModelBuilder id(long id);
TestManyTypesViewModelBuilder id(@Nullable Number... ids);
TestManyTypesViewModelBuilder id(long id1, long id2);
TestManyTypesViewModelBuilder id(@Nullable CharSequence key);
TestManyTypesViewModelBuilder id(@Nullable CharSequence key, @Nullable CharSequence... otherKeys);
TestManyTypesViewModelBuilder id(@Nullable CharSequence key, long id);
TestManyTypesViewModelBuilder layout(@LayoutRes int layoutRes);
TestManyTypesViewModelBuilder spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback spanSizeCallback);
}
| 8,496 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/PropDefaultsView_throwsForNonStaticValue.java | package com.airbnb.epoxy;
import android.content.Context;
import androidx.annotation.Nullable;
import android.view.View;
@ModelView(defaultLayout = 1)
public class PropDefaultsView_throwsForNonStaticValue extends View {
final int PRIMITIVE_DEFAULT = 23;
public PropDefaultsView_throwsForNonStaticValue(Context context) {
super(context);
}
@ModelProp(defaultValue = "PRIMITIVE_DEFAULT")
public void primitiveWithExplicitDefault(int title) {
}
}
| 8,497 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/PropDefaultsView_throwsForPrivateValue.java | package com.airbnb.epoxy;
import android.content.Context;
import android.view.View;
@ModelView(defaultLayout = 1)
public class PropDefaultsView_throwsForPrivateValue extends View {
private static final int PRIMITIVE_DEFAULT = 23;
public PropDefaultsView_throwsForPrivateValue(Context context) {
super(context);
}
@ModelProp(defaultValue = "PRIMITIVE_DEFAULT")
public void primitiveWithExplicitDefault(int title) {
}
} | 8,498 |
0 | Create_ds/epoxy/epoxy-processortest/src/test | Create_ds/epoxy/epoxy-processortest/src/test/resources/RequireAbstractModelPassesClassWithAttribute.java | package com.airbnb.epoxy.configtest;
import com.airbnb.epoxy.EpoxyAttribute;
import com.airbnb.epoxy.EpoxyModel;
public abstract class RequireAbstractModelPassesClassWithAttribute extends EpoxyModel<Object> {
@EpoxyAttribute String value;
@Override
protected int getDefaultLayout() {
return 0;
}
} | 8,499 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.