KivaKit 스니펫 #10

Jan 04 2023
KivaKit에 대한 추가 정보 https://state-of-the-art.org/https://www.
암호

package com.telenav.kivakit.snippets;

import com.telenav.kivakit.core.string.FormatProperty;
import com.telenav.kivakit.core.string.ObjectFormatter;

public class Snippet10 extends BaseSnippet
{
    public static void main(String[] args)
    {
        new Snippet10().run();
    }

    public class Alien
    {
        @FormatProperty
        private final String name;

        @FormatProperty
        private final Galaxy galaxy;

        public Alien(String name, Galaxy galaxy)
        {
            this.name = name;
            this.galaxy = galaxy;
        }

        @Override
        public String toString()
        {
            return new ObjectFormatter(this).toString();
        }
    }

    public class Galaxy
    {
        @FormatProperty
        private final String name;

        public Galaxy(String name)
        {
            this.name = name;
        }
    }

    @Override
    protected Object onSnippet()
    {
        return new Alien("Fred", new Galaxy("Andromeda")).toString();
    }
}

      
                
Output
[Snippet10.Alien galaxy = [Snippet10.Galaxy name = Andromeda], name = Fred]

KivaKit에 대한 추가 정보

https://state-of-the-art.org/
https://www.kivakit.org/

관련 기사

KivaKit 스니펫 #1
KivaKit 스니펫 #2
KivaKit 스니펫 #3

지금까지 본 대부분의 Java가 실제 Java가 아닌 6가지 이유
호스트가 문자열이 아니고 포트가 정수가 아닌 이유
정수가 개수가 아닌 이유
모든 것이 분할 정복입니다 .