一个简单的亲属关系计算算法实现
package com.zifamily.zfapp.sns;
import org.apache.commons.collections.CollectionUtils;
import org.junit.Before;
import org.junit.Test;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.stream.Collectors;
/**
* 家人关系推算
* @author QYF
* @Title: RoleReckonTest
* @Date: 2018/12/14 11:48
*/
public class RoleReckonTest {
//【关系】f:父,m:母,h:夫,w:妻,s:子,d:女
//【修饰符】 1:男性,0:女性
public HashMap<String,String> roleMap=new HashMap();
/**
* 角色性别 1--男性 ;0--女性
*/
public HashMap<String,String> roleSex=new HashMap();
/**
* 角色反转
*/
public HashMap<String,String> roleRef=new HashMap();
@Before
public void addData(){
// roleMap.put("jr","家人");
roleMap.put("f,f","爷爷");
roleMap.put("f,m","奶奶");
roleMap.put("m,f","外公");
roleMap.put("m,m","外婆");
roleMap.put("f","爸爸");
roleMap.put("m","妈妈");
roleMap.put("h,f","公公");
roleMap.put("h,m","婆婆");
roleMap.put("w,f","岳父");
roleMap.put("w,m","岳母");
roleMap.put("f,ob","伯父");
roleMap.put("f,ob,w","伯母");
roleMap.put("f,lb","叔叔");
roleMap.put("f,lb,w","婶婶");
roleMap.put("f,os","姑母"); //????
roleMap.put("f,ls","姑姐"); //????
roleMap.put("f,xs,h","姑丈"); //????
roleMap.put("m,ob","大舅");
roleMap.put("m,ob,w","大舅妈");
roleMap.put("m,lb","小舅");
roleMap.put("m,lb,w","小舅妈");
roleMap.put("m,os","大姨");
roleMap.put("m,os,h","大姨父");
roleMap.put("m,ls","小姨");
roleMap.put("m,ls,h","小姨父");
roleMap.put("ob","哥哥");
roleMap.put("os","姐姐");
roleMap.put("lb","弟弟");
roleMap.put("ls","妹妹");
roleMap.put("ob,w","嫂子");
roleMap.put("lb,w","弟妹");
roleMap.put("os,h","姐夫");
roleMap.put("ls,h","妹夫");
roleMap.put("f,xb,s&o","堂哥"); //解析?
roleMap.put("f,xb,d&o","堂姐"); //解析?
roleMap.put("f,xb,d&l","堂妹");
roleMap.put("f,xb,s&l","堂弟");
roleMap.put("f,xs,s&o","表哥"); //姑表哥
roleMap.put("m,xb,s&o","表哥"); //舅表哥
roleMap.put("m,xs,s&o","表哥"); //姨表哥
roleMap.put("m,xb,d&o","表姐"); //舅表姐
roleMap.put("m,xs,d&o","表姐"); //姨表姐
roleMap.put("f,xs,d&o","表姐"); //姑表姐
roleMap.put("f,xs,s&l","表弟"); //姑表弟
roleMap.put("m,xb,s&l","表弟"); //舅表弟
roleMap.put("m,xs,s&l","表弟"); //姨表弟
roleMap.put("m,xb,d&l","表妹"); //舅表妹
roleMap.put("m,xs,d&l","表妹"); //姨表妹
roleMap.put("f,xs,d&l","表妹"); //姑表妹
roleMap.put("h","老公");
roleMap.put("h,ob","大伯子");
roleMap.put("h,lb","小叔子");
roleMap.put("h,os","大姑子");
roleMap.put("h,ls","小姑子");
roleMap.put("h,ob,w","大婶子");
roleMap.put("h,lb,w","小婶子");
roleMap.put("h,os,h","大姑夫"); //大姑子的老公?
roleMap.put("h,ls,h","小姑夫"); //小姑子的老公?
roleMap.put("w","老婆");
roleMap.put("w,ob","大舅子&#