Skip to content

kikuchy/genum

Repository files navigation

Genum - Generate Enum from YAML

Build Status

Genum is the code generator that generate Java enum class file from YAML array.

You can share the definition between server side and client application!

For example, here is a array written in YAML format.

- Tokyo
- NewYork
- London
- Beijing
- Paris
- Roma

Genum turns it into Enum java file.

package com.example;

public enum City {
  TOKYO,

  NEW_YORK,

  LONDON,

  BEIJING,

  PARIS,

  ROMA
}

Usage

CLI tool

Download latest cli tool and unzip it.

$ ./bin/genus-cli -c City -p com.example -s cities.yml -o your/project/src/main/java

Run without any option to show command line option discription.

 -c (--class-name) VAL   : Class name of Enum class.
 -o (--output) FILE      : Destination directory. Package directory will make
                           automatically.
 -p (--package-name) VAL : Package name that used for 'package' statement.
 -s (--source) FILE      : Source YAML file.

Library

Download latest library and unzip it.

Maybe, Genum will be registed to Maven Central.

It's inspired from...

License

Copyright 2015 kikuchy

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.