lombok notes

@Getter and @Setter

https://projectlombok.org/features/GetterSetter

作用目标

  • 字段

生成 gettter 名称

  • 普通类型

    • foo –> getFool()
  • boolean

    • foo –> isFool()

javadoc 转换

  • @param @return 会被自动转换到生成代码的对应位置

    • 原始代码

Gradle Notes

运行

  1. 配置
1
2
3
  apply plugin: 'application'

  mainClassName = 'hello.HelloWorld'
  1. gradlew run

打包

  • 配置

    1
    2
    3
    4
    
      jar {
    baseName = 'gs-gradle'
    version =  '0.1.0'
      }
  • gradlw build

依赖

1
2
3
4
  dependencies {
compile "joda-time:joda-time:2.2"
testCompile "junit:junit:4.12"
  }

版本

1
2
  sourceCompatibility = 1.8
  targetCompatibility = 1.8

命令

gradlew tasks

gradlew build

  • 配置

Java IO

文件与路径

File 类

  • 用于文件本身属性和操作(增删改查)

Java 7 新包

java.nio.file https://blog.csdn.net/qq877728715/article/details/104499687/

Files 类

  • 文件复制,linux 属性 rwx 等高级功能

Path 类

  • 新工具,用来取代 java.io.file.File 类

Java Collections Notes

map

使用

  • 使用 Map<KeyType, ValueType> 声明引用变量
  • 使用实现类(如:new HashMap<>()),创建被引用对象

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    
      @RestController
      public class ProductServiceController {
    private static Map<String, Product> productRepo = new HashMap<>();
    static {
     Product honey = new Product();
     honey.setId("1");
     honey.setName("Honey");
     productRepo.put(honey.getId(), honey);
     
     Product almond = new Product();
     almond.setId("2");
     almond.setName("Almond");
     productRepo.put(almond.getId(), almond);
    }
      }

实现类

  • HashMap