Skip to content

Commit

Permalink
Merge pull request #41 from zeoflow/listeners-name
Browse files Browse the repository at this point in the history
Added `I` before interface name
  • Loading branch information
teogor authored Apr 13, 2021
2 parents cd71e81 + d3bf612 commit 3b9f8e7
Show file tree
Hide file tree
Showing 20 changed files with 54 additions and 54 deletions.
2 changes: 1 addition & 1 deletion demo/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
# hide the original source file value.
#-renamesourcefileattribute SourceFile

-keep public class * implements com.zeoflow.memo.annotation.MemoStorageImpl { *; }
-keep public class * implements com.zeoflow.memo.annotation.IMemoStorageImpl { *; }
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
package com.zeoflow.memo.annotation;

/**
* MemoChangedListener is an interface of the listening for
* IMemoChangedListener is an interface of the listening for
*
* <p>SharedPreference persistence's value changes.
*/
public interface MemoChangedListener
public interface IMemoChangedListener
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.zeoflow.memo.annotation;

public interface MemoStorageImpl
public interface IMemoStorageImpl
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import com.zeoflow.jx.file.TypeSpec;
import com.zeoflow.memo.annotation.Encoder;
import com.zeoflow.memo.annotation.InjectPreference;
import com.zeoflow.memo.annotation.MemoStorageImpl;
import com.zeoflow.memo.annotation.IMemoStorageImpl;

import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement;
Expand Down Expand Up @@ -64,9 +64,9 @@ public TypeSpec generate()
{
return TypeSpec.classBuilder(getClazzName())
.addJavadoc("Injector Class for $T\n", TypeName.get(injectedElement.asType()))
.addJavadoc("Generated by Storage (https://github.com/zeoflow/storage).\n")
.addJavadoc("Generated by IStorage (https://github.com/zeoflow/storage).\n")
.addModifiers(PUBLIC)
.addSuperinterface(MemoStorageImpl.class)
.addSuperinterface(IMemoStorageImpl.class)
.superclass(TypeName.get(injectedElement.asType()))
.addMethod(getConstructorSpec())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import com.zeoflow.jx.file.ParameterSpec;
import com.zeoflow.jx.file.ParameterizedTypeName;
import com.zeoflow.jx.file.TypeSpec;
import com.zeoflow.memo.annotation.MemoChangedListener;
import com.zeoflow.memo.annotation.IMemoChangedListener;

import java.util.List;

Expand Down Expand Up @@ -54,7 +54,7 @@ public TypeSpec generateInterface()
TypeSpec.Builder builder =
TypeSpec.interfaceBuilder(getClazzName())
.addModifiers(PUBLIC)
.addSuperinterface(MemoChangedListener.class)
.addSuperinterface(IMemoChangedListener.class)
.addMethod(getOnChangedSpec());
return builder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public PreferenceComponentGenerator(
public TypeSpec generate()
{
return TypeSpec.classBuilder(getClazzName())
.addJavadoc("Generated by Storage (https://github.com/zeoflow/storage).\n")
.addJavadoc("Generated by IStorage (https://github.com/zeoflow/storage).\n")
.addModifiers(PUBLIC)
.addSuperinterface(annotatedClazz.typeName)
.addField(getInstanceFieldSpec())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public TypeSpec generate()
TypeSpec.Builder builder =
TypeSpec.classBuilder(getClazzName())
.addJavadoc("Preference class for $T\n", ClassName.get(annotatedClazz.annotatedElement))
.addJavadoc("Generated by Storage (https://github.com/zeoflow/storage).\n")
.addJavadoc("Generated by IStorage (https://github.com/zeoflow/storage).\n")
.addModifiers(PUBLIC)
.superclass(ClassName.get(annotatedClazz.annotatedElement))
.addFields(getFieldSpecs());
Expand Down
18 changes: 9 additions & 9 deletions memo/src/main/java/com/zeoflow/memo/DefaultMemoFacade.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.zeoflow.memo;

public class DefaultMemoFacade implements MemoFacade
public class DefaultMemoFacade implements IMemoFacade
{

private final Storage storage;
private final Converter converter;
private final IStorage storage;
private final IConverter converter;
private final Encryption encryption;
private final Serializer serializer;
private final LogInterceptor logInterceptor;
private final ISerializer serializer;
private final ILogInterceptor logInterceptor;

public DefaultMemoFacade(MemoBuilder builder)
{
Expand Down Expand Up @@ -39,7 +39,7 @@ public <T> boolean put(String key, T value)
log("Memo.put -> Converted to " + plainText);
if (plainText == null)
{
log("Memo.put -> Converter failed");
log("Memo.put -> IConverter failed");
return false;
}

Expand Down Expand Up @@ -132,7 +132,7 @@ public <T> T get(String key)
log("Memo.get -> Converted to : " + result);
} catch (Exception e)
{
log("Memo.get -> Converter failed");
log("Memo.get -> IConverter failed");
}

return result;
Expand All @@ -155,7 +155,7 @@ public <T> String encrypt(T value)
log("Memo.put -> Converted to " + plainText);
if (plainText == null)
{
log("Memo.put -> Converter failed");
log("Memo.put -> IConverter failed");
return "";
}

Expand Down Expand Up @@ -223,7 +223,7 @@ public <T> T decrypt(String value)
log("Memo.get -> Converted to : " + result);
} catch (Exception e)
{
log("Memo.get -> Converter failed");
log("Memo.get -> IConverter failed");
}

return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* @see MemoConverter
*/
public interface Converter
public interface IConverter
{

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* Interceptor for all logs happens in the library
*/
public interface LogInterceptor
public interface ILogInterceptor
{

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.zeoflow.memo;

public interface MemoFacade
public interface IMemoFacade
{

<T> boolean put(String key, T value);
Expand All @@ -25,7 +25,7 @@ public interface MemoFacade

void destroy();

class EmptyMemoFacade implements MemoFacade
class EmptyMemoFacade implements IMemoFacade
{

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

/**
* Intermediate layer that handles serialization/deserialization for the end result.
* This is not the same as {@link Serializer}. This interface is only used to convert the intermediate value
* into String or vice-versa to be used for {@link Storage}
* This is not the same as {@link ISerializer}. This interface is only used to convert the intermediate value
* into String or vice-versa to be used for {@link IStorage}
*
* <p>Use custom implementation if built-in implementation is not enough.</p>
*
* @see ZsonParser
*/
public interface Parser
public interface IParser
{

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
* @see MemoSerializer
*/
public interface Serializer
public interface ISerializer
{

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
* @see SharedPreferencesStorage
*/
public interface Storage
public interface IStorage
{

/**
Expand Down
2 changes: 1 addition & 1 deletion memo/src/main/java/com/zeoflow/memo/Memo.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
public final class Memo
{

static MemoFacade memoFacade = new MemoFacade.EmptyMemoFacade();
static IMemoFacade memoFacade = new IMemoFacade.EmptyMemoFacade();

private Memo()
{
Expand Down
30 changes: 15 additions & 15 deletions memo/src/main/java/com/zeoflow/memo/MemoBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ public class MemoBuilder
private static final String STORAGE_TAG_DO_NOT_CHANGE = "MemoStorage";

private final Context context;
private Storage cryptoStorage;
private Converter converter;
private Parser parser;
private IStorage cryptoStorage;
private IConverter converter;
private IParser parser;
private Encryption encryption;
private Serializer serializer;
private LogInterceptor logInterceptor;
private ISerializer serializer;
private ILogInterceptor logInterceptor;

public MemoBuilder()
{
Expand All @@ -34,7 +34,7 @@ public MemoBuilder(Context context)

this.context = context.getApplicationContext();
}
LogInterceptor getLogInterceptor()
ILogInterceptor getLogInterceptor()
{
if (logInterceptor == null)
{
Expand All @@ -45,46 +45,46 @@ LogInterceptor getLogInterceptor()
}
return logInterceptor;
}
public MemoBuilder setLogInterceptor(LogInterceptor logInterceptor)
public MemoBuilder setLogInterceptor(ILogInterceptor logInterceptor)
{
this.logInterceptor = logInterceptor;
return this;
}
Storage getStorage()
IStorage getStorage()
{
if (cryptoStorage == null)
{
cryptoStorage = new SharedPreferencesStorage(context, STORAGE_TAG_DO_NOT_CHANGE);
}
return cryptoStorage;
}
public MemoBuilder setStorage(Storage storage)
public MemoBuilder setStorage(IStorage storage)
{
this.cryptoStorage = storage;
return this;
}
Converter getConverter()
IConverter getConverter()
{
if (converter == null)
{
converter = new MemoConverter(getParser());
}
return converter;
}
public MemoBuilder setConverter(Converter converter)
public MemoBuilder setConverter(IConverter converter)
{
this.converter = converter;
return this;
}
Parser getParser()
IParser getParser()
{
if (parser == null)
{
parser = new ZsonParser(new Zson());
}
return parser;
}
public MemoBuilder setParser(Parser parser)
public MemoBuilder setParser(IParser parser)
{
this.parser = parser;
return this;
Expand All @@ -106,15 +106,15 @@ public MemoBuilder setEncryption(Encryption encryption)
this.encryption = encryption;
return this;
}
Serializer getSerializer()
ISerializer getSerializer()
{
if (serializer == null)
{
serializer = new MemoSerializer(getLogInterceptor());
}
return serializer;
}
public MemoBuilder setSerializer(Serializer serializer)
public MemoBuilder setSerializer(ISerializer serializer)
{
this.serializer = serializer;
return this;
Expand Down
8 changes: 4 additions & 4 deletions memo/src/main/java/com/zeoflow/memo/MemoConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
* Serializable types will be encoded/decoded object stream
* Not serializable objects will be encoded/decoded by parser
*/
final class MemoConverter implements Converter
final class MemoConverter implements IConverter
{

private final Parser parser;
private final IParser parser;

public MemoConverter(Parser parser)
public MemoConverter(IParser parser)
{
if (parser == null)
{
throw new NullPointerException("Parser should not be null");
throw new NullPointerException("IParser should not be null");
}
this.parser = parser;
}
Expand Down
6 changes: 3 additions & 3 deletions memo/src/main/java/com/zeoflow/memo/MemoSerializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
import java.util.Map;
import java.util.Set;

class MemoSerializer implements Serializer
class MemoSerializer implements ISerializer
{

private static final char DELIMITER = '@';
private static final String INFO_DELIMITER = "#";
private static final char NEW_VERSION = 'V';

private final LogInterceptor logInterceptor;
private final ILogInterceptor logInterceptor;

MemoSerializer(LogInterceptor logInterceptor)
MemoSerializer(ILogInterceptor logInterceptor)
{
this.logInterceptor = logInterceptor;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import android.content.Context;
import android.content.SharedPreferences;

final class SharedPreferencesStorage implements Storage
final class SharedPreferencesStorage implements IStorage
{

private final SharedPreferences preferences;
Expand Down
2 changes: 1 addition & 1 deletion memo/src/main/java/com/zeoflow/memo/ZsonParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import java.lang.reflect.Type;

public final class ZsonParser implements Parser
public final class ZsonParser implements IParser
{

private final Zson zson;
Expand Down

0 comments on commit 3b9f8e7

Please sign in to comment.