Skip to content

Commit

Permalink
refactor/#368 : 팩토리 메서드 패턴을 사용하여 각 분석 도메인을 생성하는 팩토리 클래스 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
hwangdaesun committed Jul 13, 2024
1 parent 5a84797 commit 8f1e9e8
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.gaebaljip.exceed.application.domain.nutritionist;

import com.gaebaljip.exceed.application.domain.meal.DailyMeal;
import com.gaebaljip.exceed.application.domain.member.Member;

public abstract class AbstractAnalyzerFactory {
public abstract Analyzer createAnalyzer(DailyMeal dailyMeal, Member member);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.gaebaljip.exceed.application.domain.nutritionist;

import com.gaebaljip.exceed.application.domain.meal.DailyMeal;
import com.gaebaljip.exceed.application.domain.member.Member;

public class CalorieAnalyzerFactory extends AbstractAnalyzerFactory {

private CalorieAnalyzerFactory() {
}

private static class SingletonHolder{
private static final CalorieAnalyzerFactory INSTANCE = new CalorieAnalyzerFactory();
}

public static CalorieAnalyzerFactory getInstance() {
return SingletonHolder.INSTANCE;
}
@Override
public CalorieAnalyzer createAnalyzer(DailyMeal dailyMeal, Member member) {
return new CalorieAnalyzer(dailyMeal, member);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.gaebaljip.exceed.application.domain.nutritionist;

import com.gaebaljip.exceed.application.domain.meal.DailyMeal;
import com.gaebaljip.exceed.application.domain.member.Member;

public class CarbohydrateAnalyzerFactory extends AbstractAnalyzerFactory {

private CarbohydrateAnalyzerFactory() {
}

private static class SingletonHolder{
private static final CarbohydrateAnalyzerFactory INSTANCE = new CarbohydrateAnalyzerFactory();
}

public static CarbohydrateAnalyzerFactory getInstance() {
return SingletonHolder.INSTANCE;
}
@Override
public CarbohydrateAnalyzer createAnalyzer(DailyMeal dailyMeal, Member member) {
return new CarbohydrateAnalyzer(dailyMeal, member);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.gaebaljip.exceed.application.domain.nutritionist;

import com.gaebaljip.exceed.application.domain.meal.DailyMeal;
import com.gaebaljip.exceed.application.domain.member.Member;

public class FatAnalyzerFactory extends AbstractAnalyzerFactory {

private FatAnalyzerFactory() {
}

private static class SingletonHolder{
private static final FatAnalyzerFactory INSTANCE = new FatAnalyzerFactory();
}

public static FatAnalyzerFactory getInstance() {
return SingletonHolder.INSTANCE;
}

@Override
public FatAnalyzer createAnalyzer(DailyMeal dailyMeal, Member member) {
return new FatAnalyzer(dailyMeal, member);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.gaebaljip.exceed.application.domain.nutritionist;

import com.gaebaljip.exceed.application.domain.meal.DailyMeal;
import com.gaebaljip.exceed.application.domain.member.Member;

public class ProteinAnalyzerFactory extends AbstractAnalyzerFactory {

private ProteinAnalyzerFactory() {
}

private static class SingletonHolder{
private static final ProteinAnalyzerFactory INSTANCE = new ProteinAnalyzerFactory();
}

public static ProteinAnalyzerFactory getInstance() {
return SingletonHolder.INSTANCE;
}
@Override
public ProteinAnalyzer createAnalyzer(DailyMeal dailyMeal, Member member) {
return new ProteinAnalyzer(dailyMeal, member);
}
}

0 comments on commit 8f1e9e8

Please sign in to comment.