zoukankan      html  css  js  c++  java
  • lamda表达式

    业务层:

        /**
         * 测试一下
         */
        @GetMapping("/test")
        public void test(@RequestBody(required = false) List<Person> roster, int low, int high) {
            roster.forEach(p -> test2(p.getAge(), low, high));
        }
    
        private void test2(int age, int low, int high) {
            if (low <= age && age < high) {
                Person.printPerson(age);
            }
        }
    

      工具类

    package com.onlyphoto.jupiteragent.controller;
    
    import java.time.LocalDate;
    
    
    public class Person {
    
        public enum Sex {
            MALE, FEMALE
        }
        int age;
        String name;
        LocalDate birthday;
        Sex gender;
        String emailAddress;
    
        public void setAge(int age) {
            this.age = age;
        }
    
        public Person(int age, String name, LocalDate birthday, Sex gender, String emailAddress) {
            this.age = age;
            this.name = name;
            this.birthday = birthday;
            this.gender = gender;
            this.emailAddress = emailAddress;
        }
    
        public Person(int age) {
            this.age = age;
        }
    
        public String getName() {
            return name;
        }
    
        public void setName(String name) {
            this.name = name;
        }
    
        public LocalDate getBirthday() {
            return birthday;
        }
    
        public void setBirthday(LocalDate birthday) {
            this.birthday = birthday;
        }
    
        public Sex getGender() {
            return gender;
        }
    
        public void setGender(Sex gender) {
            this.gender = gender;
        }
    
        public String getEmailAddress() {
            return emailAddress;
        }
    
        public void setEmailAddress(String emailAddress) {
            this.emailAddress = emailAddress;
        }
    
        public int getAge() {
            // ...
            return this.age;
        }
    
        public static void printPerson(int age) {
            // ...
    //        this.age = age;
            System.out.println("年龄在合适范围的为: " + age);
        }
    }
    

      

  • 相关阅读:
    LCS(最长公共子序列)
    如何利用MAXScript代码进行DNA双螺旋结构的创建
    如何在3ds MAX中进行宏脚本MacroScript的编写
    3dsmax:[5]maxscript是干什么的
    Visual MAXScript 工具
    3D MAXScript(1)
    如何写3DMAX的插件
    利用GitHub for Window 来进行项目的上传
    VS中的库
    软件测试作业
  • 原文地址:https://www.cnblogs.com/MaxElephant/p/14977939.html
Copyright © 2011-2022 走看看