Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
daisuke-nomura committed Feb 26, 2017
1 parent 9031e76 commit 6ddfdb3
Show file tree
Hide file tree
Showing 52 changed files with 1,460 additions and 4 deletions.
71 changes: 71 additions & 0 deletions .gitignore
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,74 @@ captures/

# Keystore files
*.jks
### Android template
# Built application files

# Files for the ART/Dalvik VM

# Java class files

# Generated files

# Gradle files

# Local configuration file (sdk path, etc)

# Proguard folder generated by Eclipse

# Log Files

# Android Studio Navigation editor temp files

# Android Studio captures folder

# Intellij
.idea/tasks.xml
.idea/libraries

# Keystore files

# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff:

# Sensitive or high-churn files:
.idea/dataSources/
.idea/dataSources.ids
.idea/dataSources.xml
.idea/dataSources.local.xml
.idea/sqlDataSources.xml
.idea/dynamic.xml
.idea/uiDesigner.xml

# Gradle:
.idea/gradle.xml

# Mongo Explorer plugin:
.idea/mongoSettings.xml

## File-based project format:
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

.idea
4 changes: 2 additions & 2 deletions LICENSE
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright {yyyy} {name of copyright owner}
Copyright 2017 Daisuke Nomura

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -198,4 +198,4 @@
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.
limitations under the License.
232 changes: 230 additions & 2 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,2 +1,230 @@
# KiiAnnotation
Annotation Processor for KiiObject
# KiiAnnotation: Annotation Processor for KiiObject

[![Release](https://jitpack.io/v/daisuke-nomura/kiiannotation.svg)](https://jitpack.io/#daisuke-nomura/kiiannotation)

KiiAnnotation is an Annotation Processor library for [KiiObject][kiiObject] of [Kii Cloud][kii].
This library generates wrapper methods for KiiObject and builder of itself.

##Sample usage

First of all, define KiiBucket name and KiiObject details.

@GroupScope(name = "hoge")
public class Group {
@Key(key = "fuga")
private String name;
}

Next, select "Build APK".

public class GroupBucket {
private KiiObject kiiObject;

private GroupBucket(KiiGroup kiiGroup) {
this.kiiObject = kiiGroup.bucket("hoge").object();
}

private GroupBucket(KiiObject kiiObject) {
this.kiiObject = kiiObject;
}

public static GroupBucket create(KiiGroup kiiGroup) {
return new com.kyaracter.kiiannotation.example.entity.GroupBucket(kiiGroup);
}

public static GroupBucket from(KiiObject kiiObject) {
return new com.kyaracter.kiiannotation.example.entity.GroupBucket(kiiObject);
}

public KiiObject kiiObject() {
return this.kiiObject;
}

public void name(String name) {
this.kiiObject.set("fuga", name);
}

public String name() {
return this.kiiObject.getString("fuga");
}

public static class Builder {
private String name;

private KiiGroup kiiGroup;

public Builder(KiiGroup kiiGroup) {
this.kiiGroup = kiiGroup;
}

public GroupBucket.Builder name(String name) {
this.name = name;
return this;
}

public GroupBucket build() {
GroupBucket groupbucket = new GroupBucket(this.kiiGroup);
groupbucket.name(this.name);
return groupbucket;
}
}
}


After that, write your code.

GroupBucket groupBucket = new GroupBucket.Builder(Kii.group("aaa"))
.name("bbb")
.build();


If you like get/set**** or don't like builder, you could enable or disable it.


###Application Scope
@ApplicationScope

@ApplicationScope(name = "app", simplify = false, builder = false, suffix = "Data")
public class App {
@Key(key = "app")
private String name;

@Key(key = "count")
private int count;
}

then

public class AppData {
private KiiObject kiiObject;

private AppData() {
this.kiiObject = com.kii.cloud.storage.Kii.bucket("app").object();
}

private AppData(KiiObject kiiObject) {
this.kiiObject = kiiObject;
}

public static AppData create() {
return new com.kyaracter.kiiannotation.example.entity.AppData();
}

public static AppData from(KiiObject kiiObject) {
return new com.kyaracter.kiiannotation.example.entity.AppData(kiiObject);
}

public KiiObject getKiiObject() {
return this.kiiObject;
}

public void setName(String name) {
this.kiiObject.set("app", name);
}

public void setCount(int count) {
this.kiiObject.set("count", count);
}

public String getName() {
return this.kiiObject.getString("app");
}

public int getCount() {
return this.kiiObject.getInt("count");
}
}

You could change suffix of class name.
The default suffix is 'Bucket'.


###Group Scope
@GroupScope

refer to sample usage.

###User Scope
@UserScope

@UserScope(name = "user", builder = false)
public class User {
@Key(key = "user")
private String name;
}

then

public class UserBucket {
private KiiObject kiiObject;

private UserBucket() {
this.kiiObject = com.kii.cloud.storage.Kii.user().bucket("user").object();
}

private UserBucket(KiiObject kiiObject) {
this.kiiObject = kiiObject;
}

public static UserBucket create() {
return new com.kyaracter.kiiannotation.example.entity.UserBucket();
}

public static UserBucket from(KiiObject kiiObject) {
return new com.kyaracter.kiiannotation.example.entity.UserBucket(kiiObject);
}

public KiiObject kiiObject() {
return this.kiiObject;
}

public void name(String name) {
this.kiiObject.set("user", name);
}

public String name() {
return this.kiiObject.getString("user");
}
}

##Binaries

allprojects {
repositories {
maven { url "https://jitpack.io" }
}
}

and

dependencies {
annotationProcessor 'com.github.daisuke-nomura.KiiAnnotation:processor:0.1.0'
compile 'com.github.daisuke-nomura:KiiAnnotation:0.1.0'
}

If you using Android Studio 2.2 or below, use [android-apt][apt] instead of 'annotationProcessor'.

##Bugs and Feedback

Please use [GitHub Issues][issues].

##License

Copyright 2017 Daisuke Nomura

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.

[kiiObject]: http://docs.kii.com/references/android/storage/latest/com/kii/cloud/storage/KiiObject.html
[kii]: https://jp.kii.com/
[apt]: https://bitbucket.org/hvisser/android-apt
[issues]: https://github.com/daisuke-nomura/KiiAnnotation/issues
1 change: 1 addition & 0 deletions annotations/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
10 changes: 10 additions & 0 deletions annotations/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apply plugin: 'java'
apply plugin: 'maven'

group='com.github.daisuke-nomura'

dependencies {
}

sourceCompatibility = "1.7"
targetCompatibility = "1.7"
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.kyaracter.kiiannotation.annotations;


import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.CLASS)
public @interface ApplicationScope {
String name();
boolean simplify() default true;
boolean builder() default true;
String suffix() default "Bucket";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.kyaracter.kiiannotation.annotations;


import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.CLASS)
public @interface GroupScope {
String name();
boolean simplify() default true;
boolean builder() default true;
String suffix() default "Bucket";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.kyaracter.kiiannotation.annotations;


import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.FIELD)
@Retention(RetentionPolicy.CLASS)
public @interface Key {
String key();
}
Loading

0 comments on commit 6ddfdb3

Please sign in to comment.